enhancement: show when context is overridden by "DOCKER_HOST" or other options
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
Piste de recherche
Commencez par lire cli/command/cli.go ainsi que la logique d’avertissement dans cli/command/context/list.go et cli/command/context/use.go. Comparez la manière dont docker version et docker info signalent actuellement Context, puis définissez le comportement de sortie et de formatage pour les Contexts remplacés et les Hosts actifs. Le travail est terminé lorsque la conception résout les alternatives ouvertes sans casser la sortie formatée ni les attentes des scripts.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
The Docker CLI defaults to using a local daemon through a unix-socket (Linux, macOS) or named pipe (Windows), but it can be configured to use a different connection, which can be a remote machine.
There's various ways to configure the CLI; (also see DockerCli.CurrentContext);
DOCKER_HOST(takes precedence over context)--host/-H(configures the connection to use)DOCKER_CONTEXT(configure the context, which is used to configure the connection)--context(configure the context, which is used to configure the connection)currentContextfield in~/.docker/config.json(configures the default context to configure the connection)- In rootless-mode, other env-vars may be involved for the default socket path.
Some of these options may not be very visible; we have some warnings when performing docker context operations to inform the user that DOCKER_HOST is set (and overrides the selected context);
https://github.com/docker/cli/blob/1d768f8983f90abaf7065c76102312eb2ffc42a4/cli/command/context/list.go#L110-L113
https://github.com/docker/cli/blob/1d768f8983f90abaf7065c76102312eb2ffc42a4/cli/command/context/use.go#L52-L55
However, other places may not show this information. Most notably docker version and docker info;
Current context (in the CLI's config) is desktop-linux;
cat ~/.docker/config.json | jq .currentContext
"desktop-linux"
However, docker version shows that the default context is used;
docker version
Client:
Version: 28.3.0-rc.1
API version: 1.42 (downgraded from 1.51)
Go version: go1.24.4
Git commit: f53bb88
Built: Fri Jun 13 18:25:06 2025
OS/Arch: darwin/arm64
Context: default
And docker info does the same;
docker info | head -n 5
Client:
Version: 28.3.0-rc.1
Context: default
Debug Mode: false
Plugins:
In the above situation, the reason was that DOCKER_HOST was set in the current shell;
env | grep DOCKER
DOCKER_HOST=ssh://swarm-test-01/var/run/docker.sock
Improvement: make active connection more visible
⚠️ This is just a draft; detailed design still needed
1. Include "Docker Host" in docker version and docker info
We can include the active host in output of docker version and docker info;
docker version
Client:
Version: 28.3.0-rc.1
API version: 1.42 (downgraded from 1.51)
Go version: go1.24.4
Git commit: f53bb88
Built: Fri Jun 13 18:25:06 2025
OS/Arch: darwin/arm64
Context: default
Docker Host: ssh://swarm-test-01/var/run/docker.sock
docker info | head -n 5
Client:
Version: 28.3.0-rc.1
Context: default
Docker Host: ssh://swarm-test-01/var/run/docker.sock
Debug Mode: false
- ☝️ alternatively, we could include this in the
Serversection, however, theServeritself may be serving the API on multiple "hosts" (e.g. both on a socket AND through tcp); https://github.com/moby/moby/pull/43459
2. Show what determined the active context
We can show "why" the given context is used, e.g.;
Context: default (context disabled because DOCKER_HOST is set)
Context: desktop-linux (from DOCKER_CONTEXT)
Context: desktop-linux (from "~/.docker/config.json`)
⚠️ the above output may be used by users in scripting (docker version | grep 'Context:');
- Generally, users should use
docker context showfor this, but it may be a breaking change - When formatting, we should make this a separate part of the template so that
docker version --format '{{.Client.Context}}'only shows the context name (same for `docker info --format``)
3. Show what determined the active "host" connection
Similar to the above; show where the connection string came from;
Docker Host: ssh://swarm-test-01/var/run/docker.sock (from DOCKER_HOST)
❓ should we also show if this comes from the active context? (when not overridden by DOCKER_HOST)? Or is that just "noise"?
Docker Host: ssh://swarm-test-01/var/run/docker.sock (from "desktop-linux" context)
or
Docker Host: ssh://swarm-test-01/var/run/docker.sock (from current context)
- Langage dominant
- Go
- Étoiles
- 6.1k
- Forks
- 2.2k
- Merge moyen
- 1 j 5 h
- PR mergées (30 j)
- 36
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de docker/cli
-
docker build treats uppercase HTTP(S) URLs as local pathsPeut-être pris @TanvirTian l’a pris il y a 4 jours. Ouvertekind/bug status/0-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 1 jour
-
`docker context export` writes a truncated tar archivePeut-être pris @2arian3 l’a pris il y a 20 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 92/100
Les mainteneurs répondent en général sous 1 jour
-
Truncating log lines at 75 characters makes them useless.Peut-être pris @locker95 l’a pris il y a 65 jours. Ouvertekind/bug status/0-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
docker/cli#7176 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
cli-plugins/hooks: max-message enforcement is off by onePeut-être pris @fallintoplace l’a pris il y a 143 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
docker/cli#7005 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
kind/feature status/0-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
docker/cli#6919 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de docker/cli
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Gentleman-Programming/engram#1899 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
OpenTollGate/tollgate-module-basic-go#949 ·
Les mainteneurs répondent en général sous 1 jour