我有一个简单的
docker-compose
version: "3.7"
services:
mongo:
image: asia.gcr.io/myproj/mymongo:latest
hostname: mongo
volumes:
- type: bind
source: $MONGO_DB_DATA
target: /data/db
command: [ "--bind_ip_all", "--replSet", "rs0", "--wiredTigerCacheSizeGB", "1.5"]
我用下面的命令在Kubernetes启动它
docker-compose config | docker stack deploy --orchestrator kubernetes --compose-file - mystack
但是,当pod因这个错误而失败时
Failed to pull image "asia.gcr.io/myproj/mymongo:latest": rpc error: code = Unknown desc = Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
我的私人注册表是gcloud。我已经使用服务帐户密钥文件按如下方式登录docker。
docker login -u _json_key -p "$(cat keyfile.json)" https://asia.gcr.io
docker-compose pull
从这个链接
https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
,我发现我需要创造
ImagePullSecrets
-
我怎么能写
ImagePullSecrets公司
我的docker中的语法组合,以便正确引用它。
-
链接中提到的方法要求您使用
.docker/config.json
“授权”:{
“asia.gcr.io”:{},
},
它不包括用户名和密码,因为我使用keyfile配置了它。我该怎么做?
-
或者有什么更简单的方法可以做到这一点?