fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.88k stars 644 forks source link

Unauthorized registry access should not be reported as "image not found" #605

Open hwellmann opened 8 years ago

hwellmann commented 8 years ago

Description

I'm starting a container via d-m-p based on an image from a registry which requires authentication. The image is not yet available in my local storage. I forgot to login or add my credentials otherwise.

Expected behaviour

Error message: Unauthorized, please use your credentials.

Actual behaviour

Error message: Image not found. (Even though the image does exist.)

This will confuse the casual user.

By the way, docker pull also responds with "image not found" in this situation, but this is no excuse. Directly invoking the registry REST API via curl, I do get a 401 status, not a 404 status.

Info

rhuss commented 7 years ago

Thanks for the report. Will try to reproduce it (if I find an registry requiring authentication ;-).

hwellmann commented 7 years ago

Just run your private registry , e.g. via docker-compose:

version: '2'
services:

    registry:
        restart: always
        image: registry:2
        ports:
        - 5000:5000
        volumes:
        - /opt/docker-registry:/var/lib/registry
        - ./config.yml:/etc/docker/registry/config.yml
        - ./registrypasswd:/etc/docker/registry/registrypasswd

config.yml:

version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  delete:
    enabled: false
  filesystem:
    rootdirectory: /var/lib/registry
  maintenance:
    readonly:
      enabled: false
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3
auth:
  htpasswd:
    realm: TEST
    path: /etc/docker/registry/registrypasswd

./registrypasswd is a password file generated by htpasswd.