Error codes & fixes: Docker errors
5 Error codes & fixes commands: Docker errors. Click a command to see what each part does.
Docker errors5
sudo usermod -aG docker $USER && newgrp dockerdocker.sock permission denied"permission denied while trying to connect to the Docker daemon socket"CautionWhat it means
Your user may not talk to /var/run/docker.sock.
Usual causes & fixes
- Note: the docker group is root-equivalent on that machine.
Diagnose: what each part of the command does
usermod -aG docker $USERadd yourself to the docker group&&thennewgrp dockerstart a shell with the new group (or log out and in)
sudo systemctl status dockerCannot connect to daemon"Cannot connect to the Docker daemon … Is the docker daemon running?"What it means
The client cannot reach dockerd.
Usual causes & fixes
- Start it:
sudo systemctl enable --now docker. - Wrong
DOCKER_HOSTor context:docker context ls.
Diagnose: what each part of the command does
systemctl status dockeris the Docker service running, and its last log lines
- Start it:
docker ps --filter publish=<port>port is already allocatedWhich container holds the host port?What it means
Another container (or process) already uses that host port.
Usual causes & fixes
- Stop/remove the other container, or map a different host port (
-p 8081:80). - Not a container?
sudo lsof -i :<port>.
Diagnose: what each part of the command does
--filter publish=<port>containers publishing that host port
- Stop/remove the other container, or map a different host port (
docker image inspect <image> --format '{{.Os}}/{{.Architecture}}'exec format errorImage built for another CPU architectureWhat it means
The binary in the image does not match the machine's CPU (e.g. an arm64 image on amd64), or a script lacks a shebang.
Usual causes & fixes
- Build for the target:
docker buildx build --platform linux/amd64,linux/arm64 …. - Script entrypoint: add
#!/bin/shas the first line.
Diagnose: what each part of the command does
image inspectimage metadata--format '{{.Os}}/{{.Architecture}}'e.g. linux/arm64 vs linux/amd64
- Build for the target:
docker logintoomanyrequestsDocker Hub pull rate limitWhat it means
Anonymous pulls from Docker Hub are rate-limited per IP.
Usual causes & fixes
- Log in (also on CI runners / nodes via imagePullSecrets).
- Use a pull-through cache or mirror the images to your own registry.
Diagnose: what each part of the command does
docker loginauthenticated pulls get a higher limit
Nothing matches.
My DevOps Playbook by Angelo John Calleja