Skip to content
Latchkey

docker context: Switch Between Docker Endpoints

Point the CLI at different Docker daemons - local or remote.

docker context manages named connections to Docker endpoints so one CLI can target multiple daemons. This page covers create/use/ls and the CI targeting gotcha.

What it does

A context bundles the endpoint (a local socket or a remote daemon over SSH/TCP) the CLI talks to. docker context use switches the active one, so docker build/run commands hit a different daemon without changing flags.

Common usage

Terminal
docker context ls
docker context create remote --docker "host=ssh://user@host"
docker context use remote
docker --context default build -t app .

Common errors in CI

"context ... does not exist" means the named context was not created on this runner - contexts are per-user config, not committed to the repo. "Cannot connect to the Docker daemon" after switching usually means the remote endpoint is unreachable (SSH/TCP/firewall). In CI prefer the default context or set DOCKER_HOST explicitly rather than relying on a context that may not exist on the runner.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →