我正在使用shippable将私有docker映像推送到Google容器注册表,然后再从笔记本电脑本地或Google Compute Engine实例内部提取。
我知道该命令gcloud preview docker pull gcr.io/projectID/image- name有效,但是我不能依赖gcloud被安装在有人可能需要从中提取映像的每台计算机上。
gcloud preview docker pull gcr.io/projectID/image- name
如果我docker-compose up -d在计算机上运行,则会出现以下错误:
docker-compose up -d
Pulling image gcr.io/projectID/image-name... Pulling repository gcr.io/projectID/image-name Traceback (most recent call last): File "<string>", line 3, in <module> File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 31, in main File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 27, in dispatch File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 59, in perform_command File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 464, in up File "/compose/build/docker-compose/out00-PYZ.pyz/compose.project", line 208, in up File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 214, in recreate_containers File "/compose/build/docker-compose/out00-PYZ.pyz/compose.service", line 199, in create_container File "/compose/build/docker-compose/out00-PYZ.pyz/compose.progress_stream", line 37, in stream_output File "/compose/build/docker-compose/out00-PYZ.pyz/compose.progress_stream", line 50, in print_output_event compose.progress_stream.StreamOutputError: Error: Status 403 trying to pull repository projectID/image-name: "Access denied."
是否可以通过某种形式的OAuth或密钥来认证或访问图像?我想避免在需要拉取映像的每台计算机上安装gcloud,并且映像必须保持私有。
我已经尝试过了,gcloud preview docker -a但这不是我要寻找的解决方案。
gcloud preview docker -a
预先感谢您的任何帮助。
如果要使用香草泊坞窗在不在Google Compute Engine(即本地)中的计算机上使用Google Container Registry,则可以按照Google的说明进行操作。
两种主要方法是使用访问令牌或JSON密钥文件。
请注意,_token和_json_key是您为用户名(-u)提供的实际值
_token
_json_key
-u
访问令牌
$ docker login -e 1234@5678.com -u _token -p "$(gcloud auth print-access-token)" https://gcr.io
JSON密钥文件
$ docker login -e 1234@5678.com -u _json_key -p "$(cat keyfile.json)" https://gcr.io
要创建密钥文件,您可以按照以下说明进行操作:
您可以在此处查看有关生成密钥文件的Google文档。