简体   繁体   English

错误无法将图像'library/web:latest'推送到注册表'docker.io'。 错误:被拒绝:请求的资源访问被拒绝 - Kompose up

[英]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.

相关问题 Docker 推送到私有注册表错误 [拒绝:请求访问资源被拒绝] - Docker push to private registry error [denied: requested access to the resource is denied] docker 推送错误“被拒绝:请求访问资源被拒绝” - docker push error "denied: requested access to the resource is denied" 运行 kompose up 时访问被拒绝错误 - Access Denied error when running kompose up Docker 推“拒绝:请求访问资源被拒绝” - Docker push "denied: requested access to the resource is denied" Docker Push在Red Hat Server中失败,错误为“ **拒绝:请求对资源的访问被拒绝**” - Docker Push has failed in Red Hat Server with error “**denied: requested access to the resource is denied**” 拒绝:将图像推送到 gitlab 注册表时请求访问资源被拒绝 - denied: requested access to the resource is denied when pushing image to gitlab registry Docker:从 docker.io 拉取图像(最新)时出错 - Docker : Error pulling image (latest) from docker.io 无法将Docker映像推送到gitlab:拒绝:请求的对资源的访问被拒绝 - Impossible to push docker images to gitlab: denied: requested access to the resource is denied Docker 推入 Jenkins - 拒绝:请求的资源访问被拒绝 - Docker push in Jenkins - denied: requested access to the resource is denied 来自 docker.io/library/build:latest containerizing svelte 的错误 - ERROR FROM docker.io/library/build:latest containerizing svelte
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM