# docker context: Switch Between Docker Endpoints

> How docker context works: managing and switching between Docker daemon endpoints (local, remote, cloud) and CI targeting.

Source: https://latchkey.dev/learn/command-reference/docker-context-command  
Updated: 2026-06-25

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.

## FAQ

### docker context: Switch Between Docker Endpoints?

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 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).

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
