docker: command not found — Fix for Ubuntu, Debian & CentOS
docker: command not found means Docker Engine is either not installed, or installed but not on your PATH. On Linux, the second most common cause is that the docker binary is installed correctly but your user is not in the docker group, causing the command to be available only to root.
Step 1: Check If Docker Is Installed
which docker
docker --version
If both return nothing, Docker is not installed. Follow the install steps below.
Fix 1: Install Docker Engine (Ubuntu / Debian)
Use the official Docker convenience script for the fastest install:
curl -fsSL https://get.docker.com | sh
This installs the latest stable Docker Engine and CLI. Verify:
docker --version
# Docker version 27.x.x, build ...
Manual Install (recommended for production)
# Remove old/conflicting packages
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do
sudo apt remove -y $pkg 2>/dev/null
done
# Add Docker's official GPG key
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Fix 2: Install Docker Engine (CentOS / AlmaLinux / RHEL)
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
Fix 3: docker Found But Requires sudo
If sudo docker ps works but docker ps doesn't, your user is not in the docker group:
sudo usermod -aG docker $USER
Then log out and back in (or run newgrp docker to apply without re-login):
newgrp docker
docker ps
Security note: Users in the
dockergroup have effective root access on the host. Only add trusted users.
Fix 4: Docker Installed But Not Running
sudo systemctl status docker
If the service is inactive or failed:
sudo systemctl start docker
sudo systemctl enable docker # start on boot
Check logs if it fails to start:
journalctl -xeu docker --no-pager | tail -30
Fix 5: Docker in PATH After Fresh Install
If you just installed Docker and docker: command not found persists:
hash -r
# or start a new shell
exec bash
The shell caches command lookups. After a fresh install, clearing the hash table or opening a new terminal resolves this.
Verify Everything Works
docker run --rm hello-world
A successful run prints a message confirming Docker is installed correctly and can pull and run images.
VMHeaven VPS Note
VMHeaven KVM VPS instances support Docker fully — unlike OpenVZ containers, KVM provides real kernel access required by Docker. If you want Docker pre-installed, you can choose a Docker-ready OS image at provisioning time, or install it manually using the steps above.