How to Start Docker
"Start Docker" means two different things. First the Docker daemon (dockerd) has to run, because the docker command is only a client that sends requests to it. Then you run or start containers. If the daemon is down, every docker command fails with:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Start the daemon on Linux (systemd)
sudo systemctl start docker # start now
sudo systemctl enable docker # start at boot
sudo systemctl enable --now docker # both in one step
systemctl status docker # check
On Debian and Ubuntu, the Docker packages start the service and enable it at boot during installation. On RHEL, Rocky, AlmaLinux and Fedora, installing from Docker's dnf repository does not start anything, so run sudo systemctl enable --now docker once after installing.
Docker also ships a docker.socket unit. With it enabled, the first client request starts the daemon on demand. That is why sudo systemctl stop docker prints a warning that the service can still be activated by docker.socket. To stop Docker completely:
sudo systemctl stop docker.socket docker.service
Docker's post-install docs also enable containerd at boot. Containerd is a dependency of the Docker service, but enabling both is harmless:
sudo systemctl enable docker.service containerd.service
WSL 2
With Docker Desktop on Windows, start Docker Desktop and turn on WSL integration for your distribution. The docker command inside WSL then talks to Docker Desktop.
With Docker Engine installed directly inside a WSL distribution, it depends on whether systemd is enabled. If /etc/wsl.conf contains:
[boot]
systemd=true
use the systemctl commands above. Without systemd, start it the old way:
sudo service docker start
macOS and Windows (Docker Desktop)
Docker Desktop runs the daemon inside a small VM. Starting the application starts Docker:
open -a Docker # macOS
docker desktop start # recent Docker Desktop versions, macOS and Windows
docker desktop status
On Windows you can also launch Docker Desktop from the Start menu. To have it running after every login, enable the setting to start Docker Desktop when you sign in, in Settings, General.
Rootless Docker
A rootless daemon runs as your user under the user's systemd instance:
systemctl --user start docker
systemctl --user enable docker
sudo loginctl enable-linger "$USER" # keep it running without an active login
Check that Docker is running
docker version # shows both Client and Server sections when the daemon answers
docker info # daemon details, fails fast if it is not reachable
docker run --rm hello-world
If docker version prints only the client part followed by an error, the daemon is not reachable.
When the daemon will not start
systemctl status docker
sudo journalctl -u docker --since "15 min ago"
Typical causes:
- Invalid
/etc/docker/daemon.json. One missing comma stops the daemon. Validate before restarting (Docker Engine 23.0 and later):sudo dockerd --validate --config-file /etc/docker/daemon.json - The same option set twice, for example
hostsindaemon.jsonand-Hin the systemd unit. The daemon refuses conflicting settings. - Disk full under
/var/lib/docker. Check withdf -h /var/lib/docker. - Permission denied instead of "cannot connect" is a different problem: the daemon runs, but your user is not allowed to use the socket. Add the user to the
dockergroup or usesudo.
Also check where the client is pointing. DOCKER_HOST or the current context can send commands to a different daemon:
echo "$DOCKER_HOST"
docker context ls
Run and start containers
Once the daemon is up, docker run creates and starts a new container from an image:
docker run -d --name web -p 8080:80 --restart unless-stopped nginx:stable
-d runs it in the background, --name gives it a fixed name, -p publishes container port 80 on host port 8080. Other options you will use often are -e for environment variables, -v for volumes, -it for an interactive shell and --rm to remove the container when it exits.
A container that already exists but is stopped is started with docker start, not docker run:
docker ps -a # running and stopped containers
docker start web # start it again with its original settings
docker restart web # stop and start
docker stop web
If a container stops right after starting, its main process exited. docker logs web usually tells you why.
Start containers automatically at boot
Two things are needed: the daemon enabled at boot (systemctl enable docker) and a restart policy on the container. Docker then starts the container when the daemon starts.
docker run -d --name web --restart unless-stopped nginx:stable
docker update --restart unless-stopped web # for an existing container
unless-stoppedrestarts after crashes and reboots, but not if you stopped the container yourself.alwaysalso brings back a container you stopped by hand, once the daemon restarts.on-failure:5restarts only after a non-zero exit, at most five times.
With Compose, set restart: unless-stopped per service and run docker compose up -d once. Restart policies do not wait for dependencies. If one service needs another to be ready, use depends_on with a health check condition in Compose, and make the app retry its connections.
Quick reference
sudo systemctl enable --now docker # Linux: start now and at boot
sudo service docker start # WSL or other systems without systemd
open -a Docker / docker desktop start # Docker Desktop
systemctl --user start docker # rootless
docker info # is the daemon reachable
sudo journalctl -u docker # why it did not start
docker run -d --restart unless-stopped IMAGE # container that comes back after reboot
docker start NAME # start an existing container
