DOCKER_HOST
Specifies the Docker daemon socket to connect to. Defaults to unix:///var/run/docker.sock on Linux and macOS. Override to connect to a remote Docker daemon over TCP or to use a custom socket path for rootless Docker.
Last updated:
DOCKER_HOST tells the Docker CLI which daemon to talk to. By default it is the local Unix socket unix:///var/run/docker.sock; set it to a tcp:// or ssh:// address to drive a remote daemon, or to a rootless/Docker Desktop/Colima socket path. It is the lever behind a lot of 'Cannot connect to the Docker daemon' errors: if DOCKER_HOST points at a daemon that is not running (or the socket path is wrong for your setup), every docker command fails before doing anything. Testcontainers, CI runners, and IDE integrations all consult it.
- Provider
- Docker
- Category
- daemon
- Set by
- Set via environment variable or Docker context configuration
- Default
- unix:///var/run/docker.sock
- Example
- tcp://192.168.1.100:2376
How to set DOCKER_HOST
remote daemon over SSH
export DOCKER_HOST=ssh://user@build-server
docker psremote daemon with TLS
export DOCKER_HOST=tcp://192.168.1.100:2376
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH=~/.docker/certsback to the local socket
unset DOCKER_HOST # or: docker context use defaultReferences
Frequently Asked Questions
Why do I get 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock'?
Either the daemon is not running, or DOCKER_HOST/your docker context points at the wrong socket. Start Docker, then check `echo $DOCKER_HOST` and `docker context ls`. On rootless Docker, Colima, or Docker Desktop the socket is not at the default path, so an exported DOCKER_HOST may be needed — or a stale one may be the problem.
Stay up to date
Get notified about new guides, tools, and cheatsheets.