我已按照指示 here ,一切正常,直到我重新启动计算机。重新启动后,docker 守护进程似乎失去了对 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 - 一个通过将 docker 的 repo 添加到 apt,一个通过 snap。运行
sudo systemctl list-unit-files| grep docker | grep enabled
展示了 docker 的两个安装:
docker.service enabled
snap.docker.dockerd.service enabled
安装两个 docker 会导致启动问题。我删除了 snap 安装,重新启动,现在一切正常。
关于docker - 重新启动后 Google Cloud Logging 驱动程序找不到凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54913571/