“ gcloud auth configure-docker”在Ubuntu上的GCP VM实例上无法正确设置? [英] "gcloud auth configure-docker" on GCP VM instance with Ubuntu not setup properly?

查看:98
本文介绍了“ gcloud auth configure-docker”在Ubuntu上的GCP VM实例上无法正确设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ubuntu 18.10在GCP上创建了一个VM实例。当我通过SSH对VM进行任何修改并尝试以下操作时:

  gcloud info 

我得到了一些警告:

 系统路径:[/ snap / google-cloud-sdk / 66 / usr / bin /:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games: / usr / local / game 
s:/ snap / bin]
Python路径:[/ snap / google-cloud-sdk / 66 / lib / third_party:/ snap / google-cloud-sdk / 66 / lib:/snap/google-cloud-sdk/66/usr/lib/python2.7 /:/ snap
/google-cloud-sdk/66/usr/lib/python2.7/plat-x86_64-linux -gnu:/snap/google-cloud-sdk/66/usr/lib/python2.7/lib-tk:/ snap / google-cloud-sdk / 6
6 / usr / lib / python2.7 / lib-old:/snap/google-cloud-sdk/66/usr/lib/python2.7/lib-dynload]
路径上的Cloud SDK:[False]
路径上的Kubectl:[False]
警告:系统PATH上有旧版本的Google Cloud Platform工具。
/ usr / bin / snap

如果我尝试通过以下方式进行身份验证:

  sudo gcloud auth configure-docker 

我看到了:

 警告:`docker-credential-gcloud`不在系统路径中。 
gcloud的Docker凭证帮助器可以配置,但是只有在解决此问题后才能使用。
警告:`docker`不在系统路径中。
`docker`和`docker-credential-gcloud`必须位于同一路径中才能正常工作。
gcloud的Docker凭证帮助器可以配置,但是只有在解决此问题后才能使用。
以下设置将添加到您的Docker配置文件

版本的gcloud已安装:

  sudo gcloud版本

Google Cloud SDK 230.0.0
alpha 2019.01.11
beta 2019.01.11
bq 2.0.39
核心2019.01.11
gsutil 4.35
kubectl 2019.01.11

在这种情况下似乎不允许我更新gcloud。



然后我安装了Docker并提取了一个docker镜像。

  sudo snap install docker 
sudo docker pull tensorflow / serving

这很好。
问题是我无法在GCP容器注册表上推送映像:

  sudo docker标签tensorflow / serving gcr。 io / xxx / tf-serving 
sudo docker push gcr.io/xxx/tf-serving
未经授权:您没有执行此操作所需的权限,并且您的凭证可能无效。要对您的请求
st进行身份验证,请按照https://cloud.google.com/container-registry/docs/advanced-authentication


,并在链接中说明我需要运行:

  sudo gcloud auth configure-docker 

如何解决此问题?

 警告:`docker-credential-gcloud`不在系统PATH中。 

我可以在DockerHub上推送映像,而不会出现任何问题。



我尝试重新安装google-cloud-sdk:

  sudo apt-get update& sudo apt-get install google-cloud-sdk 

但是现在我需要使用:

  sudo gcloud alpha auth configure-docker 

,最后我仍然无法推送图像。



这似乎与某些路径问题有关:

  Cloud SDK在PATH上:[False] 
Kubectl在PATH上:[False]
警告:有旧版本的Google Cloud Platform工具在系统PATH上。
/ usr / bin / snap

有什么想法吗?我确实按照GCP文档进行了逐步操作。我还查看了GCP IAM,以授予对我的存储桶的某些访问权限。



我是GCP和Cloud的新手,所以我可能会错过一些显而易见的东西。顺便说一句,我需要使用shell脚本构建Docker映像,所以我需要使用这种类型的VM,因为在另一台已经预先安装了很多东西的VM上,都安装了 noexec标志。

解决方案

这是现在正在工作的(感谢Google的帮助)



设置:




  • 选择Ubuntu 18.10(GNU / Linux 4.18.0-1005-gcp x86_64)

    添加20 GB磁盘+允许对每个API进行http和http

    设置访问权限->存储:读写

  • sudo snap删除google-cloud-sdk

  • curl https://sdk.cloud.google.com | bash

  • 重新连接到虚拟机

  • 安装docker > https://docs.docker.com/install/linux/docker-ce/ubuntu/

    sudo apt-get删除docker docker -engine docker.io容器化runc

    sudo apt-get update

    sudo apt-get install br

    apt-transport-https \

    ca证书br

    curl \

    gnupg-agent \

    software-properties-common

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key添加-

    sudo add-apt-repository \

    deb [arch = amd64] https://download.docker.com/linux/ubuntu \

    $(lsb_release -cs)\

    stable

    sudo apt-get update

    sudo apt-get install docker-ce docker-ce-cli containerd.io

    sudo docker run hello -world#test

  • sudo usermod -a -G docker登录

  • 重新连接到虚拟机

  • gcloud auth configure-docker



在GCP上测试docker pull / push




  • docker pull tensorflow / serving

  • docker标签tensorflow / serving gcr.io/BUCKET_NAME/tf-serving

  • docker push gcr .io / BUCKET_NAME / tf-serving

    (如果创建虚拟机时不授予写访问权限,请使用 gcloud auth login)



现在可以使用


I created a VM instance on GCP using Ubuntu 18.10. When I SSH the VM without any modification and try:

gcloud info

I got some Warning:

System PATH: [/snap/google-cloud-sdk/66/usr/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/game
s:/snap/bin]
Python PATH: [/snap/google-cloud-sdk/66/lib/third_party:/snap/google-cloud-sdk/66/lib:/snap/google-cloud-sdk/66/usr/lib/python2.7/:/snap
/google-cloud-sdk/66/usr/lib/python2.7/plat-x86_64-linux-gnu:/snap/google-cloud-sdk/66/usr/lib/python2.7/lib-tk:/snap/google-cloud-sdk/6
6/usr/lib/python2.7/lib-old:/snap/google-cloud-sdk/66/usr/lib/python2.7/lib-dynload]
Cloud SDK on PATH: [False]
Kubectl on PATH: [False]
WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
  /usr/bin/snap

If I try to authenticate with:

sudo gcloud auth configure-docker

I see:

WARNING: `docker-credential-gcloud` not in system PATH.
gcloud's Docker credential helper can be configured but it will not work until this is corrected.
WARNING: `docker` not in the system PATH.
`docker` and `docker-credential-gcloud` need to be in same PATH in order to work correctly together.
gcloud's Docker credential helper can be configured but it will not work until this is corrected.
The following settings will be added to your Docker config file 

It seems that a quite recent version of gcloud is installed:

sudo gcloud version

Google Cloud SDK 230.0.0
alpha 2019.01.11
beta 2019.01.11
bq 2.0.39
core 2019.01.11
gsutil 4.35
kubectl 2019.01.11

It doesn't seem I am allowed to update gcloud on such instance.

Then I installed Docker and pulled a docker image.

sudo snap install docker
sudo docker pull tensorflow/serving

This is working fine. The issue is that I cannot push the image on GCP Container Registry:

sudo docker tag tensorflow/serving gcr.io/xxx/tf-serving
sudo docker push gcr.io/xxx/tf-serving
Unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request
st, follow the steps in https://cloud.google.com/container-registry/docs/advanced-authentication

and in the link it is explained that I need to run:

sudo gcloud auth configure-docker

How do I fix the issue? The issue is already present when I SSH the VM ?

WARNING: `docker-credential-gcloud` not in system PATH.

I can push the image on DockerHub without any issue.

I tried to reinstall google-cloud-sdk:

sudo apt-get update && sudo apt-get install google-cloud-sdk

But now I need to use:

sudo gcloud alpha auth configure-docker

and the end I still cannot push the image.

It seems to be related to some path issue:

Cloud SDK on PATH: [False]
Kubectl on PATH: [False]
WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
  /usr/bin/snap

Any idea? I did follow the GCP documentation step by step. I also look at GCP IAM to grant some access on my bucket.

I am new on GCP and Cloud so I am probably missing something obvious. By the way, I need to build a Docker image using a shell script so I need to use such type of VM because on the other VM for which a lot of stuff is already pre-installed are mounted with "noexec" flag.

解决方案

Here is what is now working (thanks Google for the help)

Setup:

  • Choose Ubuntu 18.10 (GNU/Linux 4.18.0-1005-gcp x86_64)
    add 20 GB disk + allow http and http
    set access for each API -> Storage : Read Write
  • sudo snap remove google-cloud-sdk
  • curl https://sdk.cloud.google.com | bash
  • reconnect to the VM
  • install docker https://docs.docker.com/install/linux/docker-ce/ubuntu/
    sudo apt-get remove docker docker-engine docker.io containerd runc
    sudo apt-get update
    sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io
    sudo docker run hello-world # test
  • sudo usermod -a -G docker LOGIN
  • reconnect to the VM
  • gcloud auth configure-docker

testing docker pull/push on GCP

  • docker pull tensorflow/serving
  • docker tag tensorflow/serving gcr.io/BUCKET_NAME/tf-serving
  • docker push gcr.io/BUCKET_NAME/tf-serving
    (if you don't give write access when creating the VM: use "gcloud auth login")

now this works

这篇关于“ gcloud auth configure-docker”在Ubuntu上的GCP VM实例上无法正确设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆