如何使用 Google Cloud Build 从主机访问来自 Docker 图像的文件
How to access a file from Docker image from the host using Google Clould Build
我想将 Docker 图像中的 node_modules.zip 移动到目录中的静态文件夹中。
目前,我的 cloudbuild.yaml 看起来如下:
- id: package_js
name: gcr.io/numom-57642/test4:latest
entrypoint: /bin/bash
waitFor: ['-']
args:
- -c
- |
mv node_modules.zip static/
当我 运行 cloud-build-local 我得到一个错误:
Step #1 - "package_js": mv: cannot stat 'node_modules.zip': No such file or directory
如何访问 node_modules.zip,它是 Docker 图片的一部分。
嗯……有趣。
我认为您的选择是正确的。
您应该能够将文件复制到默认安装的 /workspace
或新安装的卷中:
- id: package_js
name: gcr.io/numom-57642/test4:latest
entrypoint: /bin/bash
volumes:
- name: 'scratch'
path: '/scratch'
args:
- -c
- |
cp node_modules.zip /workspace
cp node_modules.zip /scratch
然后:
- id: check
name: busybox
volumes:
- name: 'scratch'
path: '/scratch'
args:
- |
ls -l /workspace
ls -l /scratch
使用 /workspace
更容易,因为您不需要安装卷,但使用 /scratch
更明确。
我想将 Docker 图像中的 node_modules.zip 移动到目录中的静态文件夹中。
目前,我的 cloudbuild.yaml 看起来如下:
- id: package_js
name: gcr.io/numom-57642/test4:latest
entrypoint: /bin/bash
waitFor: ['-']
args:
- -c
- |
mv node_modules.zip static/
当我 运行 cloud-build-local 我得到一个错误:
Step #1 - "package_js": mv: cannot stat 'node_modules.zip': No such file or directory
如何访问 node_modules.zip,它是 Docker 图片的一部分。
嗯……有趣。
我认为您的选择是正确的。
您应该能够将文件复制到默认安装的 /workspace
或新安装的卷中:
- id: package_js
name: gcr.io/numom-57642/test4:latest
entrypoint: /bin/bash
volumes:
- name: 'scratch'
path: '/scratch'
args:
- -c
- |
cp node_modules.zip /workspace
cp node_modules.zip /scratch
然后:
- id: check
name: busybox
volumes:
- name: 'scratch'
path: '/scratch'
args:
- |
ls -l /workspace
ls -l /scratch
使用 /workspace
更容易,因为您不需要安装卷,但使用 /scratch
更明确。