[英]ERROR Unable to push image 'library/web:latest' to registry 'docker.io'. Error: denied: requested access to the resource is denied - Kompose up
I have a simple docker-compose.yml
file defined this way:我有一个这样定义的简单
docker-compose.yml
文件:
version: '3'
services:
db:
image: postgres:10.5-alpine
ports:
- 5432:5432
volumes:
- ./tmp/postgres_data:/var/lib/postgresql/data
web:
build:
context: .
dockerfile: Dockerfile
command: /bin/bash -c "rm -f /tmp/server.pid && bundle exec rails server -b 0.0.0.0 -P /tmp/server.pid"
ports:
- 3000:3000
depends_on:
- db
volumes:
- .:/app
I'm using [ Kompose ] ( https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/#kompose-up ) for converting my docker-compose.yml
to Kubernetes I'm using [ Kompose ] ( https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/#kompose-up ) for converting my
docker-compose.yml
to Kubernetes
When I do kompose convert
, everything looks fine.当我做
kompose convert
时,一切看起来都很好。
This is the output:这是 output:
✗ kompose convert
INFO Kubernetes file "db-service.yaml" created
INFO Kubernetes file "web-service.yaml" created
INFO Kubernetes file "db-deployment.yaml" created
INFO Kubernetes file "db-claim0-persistentvolumeclaim.yaml" created
INFO Kubernetes file "web-deployment.yaml" created
INFO Kubernetes file "web-claim0-persistentvolumeclaim.yaml" created
My issue is when I do kompose up
I get the following errors我的问题是当我
kompose up
时出现以下错误
✗ kompose up
WARN Volume mount on the host "/Users/salo/Desktop/ibm-watson-ruby/tmp/postgres_data" isn't supported - ignoring path on the host
INFO Build key detected. Attempting to build image 'web'
INFO Building image 'web' from directory 'ibm-watson-ruby'
INFO Image 'web' from directory 'ibm-watson-ruby' built successfully
INFO Push image enabled. Attempting to push image 'web'
INFO Pushing image 'library/web:latest' to registry 'docker.io'
WARN Unable to retrieve .docker/config.json authentication details. Check that 'docker login' works successfully on the command line.: Failed to read authentication from dockercfg
INFO Authentication credentials are not detected. Will try push without authentication.
INFO Attempting authentication credentials 'docker.io
ERRO Unable to push image 'library/web:latest' to registry 'docker.io'. Error: denied: requested access to the resource is denied
FATA Error while deploying application: k.Transform failed: Unable to push Docker image for service web: unable to push docker image(s). Check that `docker login` works successfully on the command line
As a note, I'm currently logged in to my Docker Hub account.作为说明,我目前登录到我的 Docker Hub 帐户。 I did
docker login
我做了
docker login
Thanks in advance: :)提前致谢: :)
Kubernetes basically requires a Docker registry to be able to work; Kubernetes 基本上需要一个 Docker 注册表才能工作; it cannot build local images.
它无法构建本地图像。 You mention you have a Docker Hub account, so you need to add a reference to that as the container's
image:
in the docker-compose.yml
file.您提到您有一个 Docker Hub 帐户,因此您需要添加对它的引用作为容器的
image:
在docker-compose.yml
文件中。
version: '3'
services:
web:
build: .
image: myname/web # <-- add this line
ports:
- 3000:3000
depends_on:
- db
# command: is in the image
# volumes: overwrite code in the image and don't work in k8s
When Kompose tries to push the image, it will use the image:
name.当 Kompose 尝试推送图像时,它将使用
image:
name。 You should be able to separately attempt to docker-compose push
which will do the same thing.您应该能够单独尝试
docker-compose push
,这将做同样的事情。
Note that I deleted the volumes:
that bind-mounts your application code into your container.请注意,我删除了
volumes:
将您的应用程序代码绑定安装到您的容器中。 This setup does not work in Kubernetes: it doesn't have access to your local system and you can't predict which node will actually be running your application.此设置在 Kubernetes 中不起作用:它无法访问您的本地系统,您无法预测哪个节点将实际运行您的应用程序。 It's worth double-checking in plain Docker that your built image works the way you expect, without overwriting its code.
值得在普通的 Docker 中仔细检查您构建的图像是否以您期望的方式工作,而不会覆盖其代码。 (Debugging this in Docker will be easier than debugging it in Kubernetes.)
(在 Docker 中调试它比在 Kubernetes 中调试它更容易。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.