【问题标题】:Google Cloud Logging Driver cannot find credentials after reboot重新启动后 Google Cloud Logging 驱动程序找不到凭据
【发布时间】:2019-07-21 15:40:20
【问题描述】:

我已按照here 的指示进行操作,在我重新启动计算机之前一切正常。重启后,docker daemon 似乎失去了对 Google 凭据的跟踪。

$ docker run --log-driver=gcplogs ...

失败:

docker: Error response from daemon: failed to initialize logging driver: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
ERRO[0000] error waiting for container: context canceled

这对我来说很奇怪,因为运行 $ systemctl show --property=Environment docker 会返回我的 systemd 配置中的值:

Environment=GOOGLE_APPLICATION_CREDENTIALS=/etc/path/to/application_default_credentials.json

如果我$ sudo systemctl restart docker,那么 docker 运行成功并且日志被发送到 stackdriver。但我希望这个 docker 映像在启动时自动运行,并且使用 sudo 重新启动 docker 会妨碍。

有没有办法用必要的环境变量初始化 docker 守护进程,这样 gcplogs 就可以在启动时准备好,而无需重新启动 docker?

【问题讨论】:

    标签: docker google-cloud-platform systemd google-cloud-stackdriver


    【解决方案1】:

    我安装了两个版本的 docker - 一个通过将 docker 的 repo 添加到 apt,一个通过 snap。跑步

    sudo systemctl list-unit-files| grep docker | grep enabled
    

    展示了两个 docker 安装:

    docker.service                             enabled    
    snap.docker.dockerd.service                enabled
    

    安装两个 docker 会导致启动问题。我删除了 snap 安装,重新启动,现在一切正常。

    【讨论】:

      【解决方案2】:

      我想你可以尝试编辑systemd: Unit dependencies and order,让docker.service在google-accounts-daemon.service之后启动。

      你可以通过 google vm 查看所有服务

      sudo systemctl list-unit-files| grep google | grep enabled
      

      你会看到

      google-accounts-daemon.service             enabled
      google-clock-skew-daemon.service           enabled
      google-instance-setup.service              enabled
      google-network-daemon.service              enabled
      google-shutdown-scripts.service            enabled
      google-startup-scripts.service             enabled
      

      【讨论】:

      • 感谢您的帮助!通过“grep google”运行 list-unit-files 并没有给我任何结果,但让我走上了使用 list-unit-files 调试的道路,这就是票。我已经通过 apt 和 snap 安装了 docker,这显然给他们的初创公司带来了问题。从 snap 中移除 docker 解决了这个问题。
      猜你喜欢
      • 2018-10-03
      • 2019-09-10
      • 2015-03-27
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多