Docker Troubleshooting Basics
Different Kinds of Errors
Wrong build path:
unable to prepare context: unable to evaluate symlinks in Dockerfile path
- You are not in the directory where Dockerfile is located
Permission issues:
WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied
Add the current user to the Docker group:
1$ sudo groupadd docker
2$ sudo usermod -aG docker $USER
Port issues:
docker: Error response from daemon: driver failed programming external connectivity on endpoint wizardly_ramanujan (...): Bind for 0.0.0.0:5000 failed: port is already allocated.
The host port you are mapping to is already occupied with another container
docker ps
to list all the running containers on the machinedocker stop <container_id>
and then retry the command
If you don’t see a port in docker ps
then it means that the port is usued by some other app
Use
lsof -i TCP:<PORT>
Kill the port that you want to use with pkill
(BE CAREFUL TO NOT STOP SOMETHING IMPORTANT)
Space Issues (CRITICAL):
Figure out how much space is used by docker with docker system df
and look at the total reclaimable column to see how much space you can save for docker
docker system prune
to delete everything that you are not using
docker container prune
, docker images prune
, docker network prune
to be more specific
Container Inspection:
docker inspect <container/image/network ID>
to get all configs of a container
Steps for basic troubleshooting
- Check for network connectivity between services
- Check for port mappings
- Check for any required volume mounts
- Check for valid image name to start services
- Check if the network used for connectivity exists
- Only supported are commands
- Check for any application-specific issues such as env variables or init scripts