I am using the command docker context use in order to set the active Docker context:
> docker context use aws-context
aws-context
However, the active Docker context does not change for some reason.
When I subsequently type docker context show, the activated context is still the default context:
> docker context show
default
When I list the existing contexts, the asterisk is still behind the default context:
> docker context ls
NAME TYPE DESCRIPTION DOCKER ENDPOINT
aws-context ecs (eu-west-1)
default * moby Current DOCKER_HOST based configuration tcp://192.168.99.100:2376
How can I change the Docker context?
If you have the DOCKER_HOST environment variable set, it will always take precedence over the newer docker context use workflow.
Type env | grep DOCKER in your shell to see if you have any docker-specific variables set. unset them by typing unset DOCKER_HOST. Other variables such as DOCKER_CONTEXT may also get in the way.
The docker context use command should work fine once that variable is out of the way.
This is noted in the docs here:
The easiest way to see what a context looks like is to view the default context.
$ docker context ls NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR default * Current... unix:///var/run/docker.sock swarmThis shows a single context called “default”. It’s configured to talk to a Swarm cluster through the local
/var/run/docker.sockUnix socket. It has no Kubernetes endpoint configured.The asterisk in the
NAMEcolumn indicates that this is the active context. This means alldockercommands will be executed against the “default” context unless overridden with environment variables such asDOCKER_HOSTandDOCKER_CONTEXT, or on the command-line with the--contextand--hostflags.
(bold added by me)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With