我使用shippable将私有泊坞广告图片推送到Google容器注册表,然后我想从笔记本电脑本地或Google Compute Engine上的实例中取出。
我知道命令gcloud preview docker pull gcr.io/projectID/image-name
有效,但我不能依赖gcloud安装在有人可能需要从中提取图像的每台机器上。
如果我在我的机器上运行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
,但这不是我正在寻找的解决方案。
提前感谢您的帮助。
答案 0 :(得分:11)
如果您想使用vanilla docker在不在Google Compute Engine(即本地)的计算机上使用Google容器注册表,您可以follow Google's instructions。
两种主要方法是使用访问令牌或JSON密钥文件。
请注意,_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
要创建密钥文件,您可以按照以下说明操作:
你可以view Google's documentation on generating a key file here。