Open enisdenjo opened 3 years ago
This is the expected behaviour for docker context use
, as it configures the default context for the CLI to use. To switch context in a specific shell, or for a single command, you can use the DOCKER_CONTEXT
environment variable instead.
That said, I think it makes sense to more explicitly mention this (and to show the alternative uses).
Awesome! Doing export DOCKER_CONTEXT=chocolate
makes sense. Thanks!
Note that with docker 20.10, we added the active context to the output of docker version
, which could be used to (e.g.) include it in your prompt; see https://github.com/docker/cli/pull/2500 (note that docker version
will still make a connection with the daemon, so it may still not be ideal, but perhaps it's useful for your scenario)
Description
Setting a Docker context with
docker context use
shares the used context between terminal sessions. This is quite dangerous IMHO and almost made me to mess up a production environment since the old behaviour attached the context exclusively to the current session.I guess this was rolled out with a new version, sure; but, since I am now paranoid and repulsive with using contexts, is there any possibility to disable this behaviour (have a context stick to the current terminal session like it was before)?
Steps to reproduce the issue:
docker context use chocolate
docker context show
printschocolate
Describe the results you received:
Opening a new terminal and doing
docker context show
printschocolate
.Describe the results you expected:
Opening a new terminal and doing
docker context show
printsdefault
.Additional information you deem important (e.g. issue happens only occasionally):
Happens consistently. And quite dangerous IMHO, simply because you might have forgotten you set a production environment context and did a
docker compose down -v
.Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
Just my Mac.