# docker context Command Reference

> Reference for docker context in CI: create, list, and switch Docker endpoints to target a remote daemon over SSH or TCP from a pipeline.

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

Manage and switch between Docker daemon endpoints.

docker context stores connection settings for Docker daemons, letting the CLI target a remote host (over SSH or TCP) instead of the local socket. In CI it is used to build or deploy against a remote Docker host without exporting DOCKER_HOST manually.

## Common subcommands

- `docker context create NAME --docker host=...` - define an endpoint
- `docker context use NAME` - make a context the default
- `docker context ls` - list contexts and show the active one
- `docker context rm NAME` - remove a context
- `docker --context NAME ...` - run a single command against a context

## Example

```shell
docker context create deploy --docker "host=ssh://ci@10.0.0.5"
docker --context deploy compose up -d
```

## In CI

Use a context to deploy to a remote Docker host over SSH from the pipeline, keeping the connection config out of every command. Prefer --context per-command over a global use so parallel steps do not fight over the active context. DOCKER_HOST achieves the same for a single endpoint.

## FAQ

### docker context Command Reference?

docker context stores connection settings for Docker daemons, letting the CLI target a remote host (over SSH or TCP) instead of the local socket. In CI it is used to build or deploy against a remote Docker host without exporting DOCKER_HOST manually.

### In CI?

Use a context to deploy to a remote Docker host over SSH from the pipeline, keeping the connection config out of every command. Prefer --context per-command over a global use so parallel steps do not fight over the active context. DOCKER_HOST achieves the same for a single endpoint.

---

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
