docker.sock means your user isn’t in the docker group: run sudo usermod -aG docker $USER and log in again. Port is already allocated means another container publishes that host port: find it with docker ps --filter publish=8080 and stop it or change the port. Cannot connect to the Docker daemon means Docker isn’t running: start it with sudo systemctl start docker.
Before you start
- Copy the exact error line. The fixes below match on the wording.
- Check what Docker is doing with
sudo systemctl status dockerandsudo journalctl -u docker -n 50 --no-pager. See read logs with journalctl.
Permission denied while trying to connect to the docker API
...to connect to the Docker daemon socket at unix:///var/run/docker.sock. Either way, your user can’t use the Docker socket.
1
Add your user to the docker group
2
Log out and back in
Group changes apply to new logins. Close the SSH session and connect again, or run
newgrp docker in the current one.3
Test
WARNING: Error loading config file: /home/alex/.docker/config.json - ... permission denied, you ran docker with sudo before. Fix the folder’s owner with sudo chown "$USER":"$USER" ~/.docker -R.
Cannot connect to the Docker daemon
failed to connect to the docker API at unix:///var/run/docker.sock; check if the path is correct and if the daemon is running.
1
Start Docker and enable it at boot
2
If it won't start, check daemon.json
A typo in A good file prints
/etc/docker/daemon.json stops the daemon. Test the file:configuration OK. A broken one names the problem, for example invalid JSON: invalid character '}' looking for beginning of object key string (a trailing comma) or the following directives don't match any configuration option.3
Check DOCKER_HOST
unset DOCKER_HOST and remove it from ~/.bashrc.df -h and see fix “No space left on device”.
Bind for 0.0.0.0:8080 failed: port is already allocated
docker stop web1), or publish yours on a free port, such as "8081:80".
failed to bind host port: address already in use
users: column names the process. Stop and disable it (for example sudo systemctl disable --now nginx) or choose another port. See check open ports on Linux.
The container name is already in use
docker rm web1 (or docker rm -f web1 if it’s running), then run your command again. Data in volumes is kept.
exec: “bash”: executable file not found in $PATH
sh but not bash. Use docker exec -it web1 sh.
Other errors you might see
Frequently asked questions
Why does my container keep restarting?
The app inside exits with an error and the restart policy starts it again. Read the reason withdocker logs --tail 50 <name>. Missing environment variables and wrong file permissions on bind mounts are the usual causes.
Why can’t I reach my container from the internet?
Check that the port is published on0.0.0.0 (docker ps), that the app inside listens on 0.0.0.0 and not 127.0.0.1, and test from outside with check if a port is open.
Why is my container reachable even though UFW blocks the port?
Docker-published ports bypass UFW. See secure Docker on a VPS.Related guides
VPS and dedicated server guides
Every guide in this section.
Docker commands cheat sheet
ps, logs, exec and more.
Install Docker
Reinstall Docker the official way.
Secure Docker on a VPS
The docker group, ports and firewalls.
Clean up Docker disk space
Free space Docker is using.
Checked against the official Docker daemon troubleshooting guide, Linux post-installation steps and Docker Hub pull limits on 4 November 2026; the permission, daemon connection, port, name conflict, executable and
daemon.json errors were reproduced on Ubuntu 24.04 LTS with Docker Engine 29.9.2. Wording can differ in other Docker releases.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026