docker / docker/cli

discrepancy in processing of config.json between 'docker login' and 'docker run'

Open
#987 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/authentication area/distribution
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description

The docker login my-server command outputs the given 'my-server' name to .docker/config.json without suffixing the default port number 443.

In the docker run command, you have to write an explicit port number for servers that have only one path segment in their name, otherwise the server name is misinterpreted as an image name. For instance, running docker run my-server/foo/bar:latest will not work, because the entire string is interpreted as an image name. Instead, running docker run my-server:443/foo/bar:latest will work, because 'my-server` is now interpreted as a host name.

However, the docker run command apparently uses simple string matching on the entries in config.json, and it does not find the login credentials it needs. It searches for my-server:443 while config.json contains my-server.

Steps to reproduce the issue:

These steps were taken from a Docker-in-Docker Jenkins job so potentially this is more than you need when you try this locally. In that case, only use the last command.

# Create config directory so that login is remembered
mkdir -p .docker
export DOCKER_CONFIG=`pwd`/.docker
# Login, using default port 443 which is NOT specified
docker login my-registry-server -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD
# Try to run a container
docker run my-registry-server:443/foo/bar:latest

Describe the results you received:

docker: Error response from daemon: Get https://my-registry-server:443/v2/foo/bar/manifests/latest: no basic auth credentials.

Describe the results you expected:

Image gets downloaded

Additional information you deem important (e.g. issue happens only occasionally):

Work-around:

# Create config directory so that login is remembered
mkdir .docker
export DOCKER_CONFIG=`pwd`/.docker
# Login, using EXPLICIT port 443
docker login my-registry-server:443 -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD
# Try to run a container
docker run my-registry-server:443/foo/bar:latest

Output of docker version:

Docker version 18.03.0-ce, build 0520e24302

Output of docker info:

Containers: 24
 Running: 0
 Paused: 0
 Stopped: 24
Images: 61
Server Version: 18.03.0-ce
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 111
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.89-boot2docker
Operating System: Boot2Docker 18.03.0-ce (TCL 8.2.1); HEAD : 404ee40 - Thu Mar 22 17:12:23 UTC 2018
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.6MiB
Name: default
ID: EZ3T:LOUY:C5PS:YCA4:QORD:2M46:TRLR:5IJF:DBWJ:AM5S:7EML:HPDU
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):
physical

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the mismatch with the documented docker login and docker run commands, using .docker/config.json and DOCKER_CONFIG as described. Trace how registry names are normalized and how credentials are selected for my-registry-server versus my-registry-server:443. Done means the documented login followed by the documented run downloads the image without requiring an explicit port during login.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
authentication, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.