Docker context with inconsistent context dir name can be listed but not used
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 2.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
Description
If I manually create directories and files for a context under $DOCKER_CONFIG/contexts/meta/… and $DOCKER_CONFIG/contexts/tls/… with a context directory name that isn't a digest of the context name, the context shows up when I list contexts, but it cannot be selected for use.
Steps to reproduce the issue:
Given a new context named foo and a made up id of abcde:
- Create valid context meta information and certificates, and place them under
$DOCKER_CONFIG/contexts/meta/abcde/meta.jsonand$DOCKER_CONFIG/contexts/tls/abcde/docker/*.pem. - Attempt to use the context.
Describe the results you received:
The context shows up when contexts are listed, but it cannot be used.
$ docker context ls --format 'table {{.Name}}\t{{.DockerEndpoint}}'
NAME DOCKER ENDPOINT
default unix:///var/run/docker.sock
foo tcp://docker-x1-api-09acb5640551d850.elb.us-west-2.amazonaws.com:2376
$ docker context use foo
context "foo" does not exist
$ docker --context foo info
unable to resolve docker endpoint: context "foo" does not exist
Describe the results you expected:
Ideally, be able to use the context.
Either the context should not be listed, or the Docker CLI shouldn't be dependent on the context's directory being a digest of the name.
Additional information you deem important (e.g. issue happens only occasionally):
Changing the directory name to 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae (digest of foo) makes it work.
Output of docker version:
Client: Docker Engine - Community
Version: 19.03.0-beta3
API version: 1.40
Go version: go1.12.4
Git commit: c55e026
Built: Thu Apr 25 19:05:38 2019
OS/Arch: darwin/amd64
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 19.03.0-beta3
API version: 1.40 (minimum version 1.12)
Go version: go1.12.4
Git commit: c55e026
Built: Thu Apr 25 19:13:00 2019
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: v1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc7+dev
GitCommit: 029124da7af7360afa781a0234d1b083550f797c
docker-init:
Version: 0.18.0
GitCommit: fec3683
Output of docker info:
N/A
Additional environment details (AWS, VirtualBox, physical, etc.):
Docker for Mac 2.0.4.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with docker context ls, docker context use foo, and docker --context foo info using mismatched context directory names. Trace how context listing resolves the name versus how selection and endpoint resolution locate it. Done means the context is either not listed or can be selected and used without requiring a digest-named directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100