This error occurs when the Docker daemon is not running or the socket file does not exist. The Docker CLI cannot communicate with the daemon because the Unix socket at /var/run/docker.sock is missing.
When you run a Docker command, the Docker CLI needs to communicate with the Docker daemon. On Linux and macOS, this communication happens through a Unix socket located at `/var/run/docker.sock`. This socket file is created by the Docker daemon when it starts. The "no such file or directory" error for docker.sock means the socket file literally does not exist on your system. This is different from permission denied errors where the socket exists but you lack access rights. Without this socket file, the Docker CLI has no way to connect to the daemon. The most common reason is that the Docker daemon (dockerd) is not running. The daemon creates the socket when it starts and removes it when it stops. Other causes include Docker not being installed correctly, the daemon being configured to use a different socket location, or the socket being accidentally deleted.
First, verify whether the Docker daemon is actually running:
On systems with systemd (most modern Linux):
sudo systemctl status dockerLook for "Active: active (running)". If it shows "inactive" or "failed", the daemon is not running.
Alternative check:
ps aux | grep dockerdIf you see a dockerd process, the daemon is running but might be using a different socket.
If Docker is not running, start the service:
Using systemctl (recommended):
sudo systemctl start dockerUsing service command (older systems):
sudo service docker startVerify it started:
sudo systemctl status dockerThe socket file should now exist:
ls -la /var/run/docker.sockTo prevent this issue after reboots, enable the Docker service:
sudo systemctl enable dockerThis creates the necessary symlinks for systemd to start Docker automatically.
Verify it's enabled:
sudo systemctl is-enabled dockerShould output "enabled".
Sometimes the Docker service gets "masked", preventing it from starting:
Check if masked:
sudo systemctl status dockerIf you see "Loaded: masked", run:
sudo systemctl unmask docker.service
sudo systemctl unmask docker.socket
sudo systemctl start dockerThis situation can occur after certain system updates or when Docker was previously disabled intentionally.
If you're using Docker Desktop on macOS or Windows:
macOS:
1. Open Finder and go to Applications
2. Double-click "Docker" to launch Docker Desktop
3. Wait for the whale icon in the menu bar to stop animating
Windows:
1. Click Start menu and search for "Docker Desktop"
2. Launch the application
3. Wait for the whale icon in the system tray to become stable
Enable default socket (Docker Desktop):
1. Open Docker Desktop Settings
2. Go to Advanced
3. Enable "Allow the default Docker socket to be used"
4. Click "Apply & Restart"
If using Docker Desktop with WSL on Windows, ensure integration is enabled:
1. Open Docker Desktop
2. Go to Settings > Resources > WSL Integration
3. Enable integration for your Linux distribution
4. Click "Apply & Restart"
Inside WSL, verify the socket:
ls -la /var/run/docker.sockIf the socket is still missing, restart WSL:
# In PowerShell (not WSL)
wsl --shutdownThen reopen your WSL terminal and try again.
If Docker is configured to use a different socket, the default location won't have a socket:
echo $DOCKER_HOSTIf this shows a value like tcp://localhost:2375 or a different socket path, either:
Option 1: Unset to use default socket:
unset DOCKER_HOST
docker infoOption 2: Point to the actual socket location:
# Find where Docker is listening
sudo find / -name "docker.sock" 2>/dev/nullCommon alternative locations:
- /run/docker.sock
- ~/.docker/run/docker.sock
- /var/run/docker/docker.sock
If you have both Snap and apt versions of Docker installed, they can conflict:
Check for Snap Docker:
snap list | grep dockerCheck for apt Docker:
dpkg -l | grep dockerIf both are present, remove one:
Remove Snap Docker:
sudo snap remove dockerOr remove apt Docker:
sudo apt remove docker docker-engine docker.io containerd runcThen restart your system and reinstall Docker using your preferred method.
If Docker is not properly installed, install it:
Ubuntu/Debian:
# Remove old versions
sudo apt remove docker docker-engine docker.io containerd runc
# Add Docker repository
sudo apt update
sudo apt install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Start and enable
sudo systemctl start docker
sudo systemctl enable dockerAfter installation, log out and back in, or restart your system.
Socket file locations by platform:
- Linux (default): /var/run/docker.sock
- macOS Docker Desktop: /var/run/docker.sock (symlink to ~/.docker/run/docker.sock)
- Windows Docker Desktop: Uses named pipe //./pipe/docker_engine (socket available in WSL)
Rootless Docker:
If you've set up rootless Docker, the socket is at a different location:
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sockChecking daemon logs:
sudo journalctl -u docker.service -eThis shows recent Docker daemon logs and can reveal why it failed to start.
Docker context issues:
Modern Docker supports contexts that can point to different daemons:
docker context ls
docker context inspect defaultIf the current context points to a non-existent socket, switch contexts:
docker context use defaultsystemd socket activation:
Docker can use socket activation where systemd manages the socket:
sudo systemctl start docker.socketThis creates the socket and starts the daemon on first connection.
SELinux/AppArmor:
On systems with SELinux or AppArmor, security policies might prevent socket creation. Check:
# SELinux
sudo ausearch -m avc -ts recent | grep docker
# AppArmor
sudo aa-status | grep dockerimage operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker
cannot open '/etc/passwd': Permission denied
How to fix 'cannot open: Permission denied' in Docker
Error response from daemon: failed to create the ipvlan port
How to fix 'failed to create the ipvlan port' in Docker
toomanyrequests: Rate exceeded for anonymous users
How to fix 'Rate exceeded for anonymous users' in Docker Hub