docker: command not found means the Docker CLI is not installed or not on your PATH. It is never bundled with Linux, so on a fresh server this is expected. Install it from Docker’s official repository rather than the often-outdated distro package.
Install with the official convenience script
The quickest correct method on Debian and Ubuntu is Docker’s own script, which adds the right repository and installs the engine plus the Compose plugin:
curl -fsSL https://get.docker.com | sudo sh
sudo systemctl enable --now dockersudo 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-compose-plugin
sudo systemctl enable --now dockerVerify
docker --version
sudo docker run --rm hello-world“docker: command found, but permission denied”
A related error: the command exists but talking to the daemon needs root. Add your user to the docker group so you can drop the sudo:
sudo usermod -aG docker $USER
# log out and back in, then:
docker ps“docker-compose: command not found”
Compose is now a subcommand, not a separate binary. The hyphenated form is retired:
docker compose version # correct
# docker-compose up # old, may be absentBoth install commands above include it, as the package docker-compose-plugin. If a script of yours still calls docker-compose, update it to the space-separated form, or give the plugin the old name once (the path of Docker’s packages):
sudo ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-composeManual installs, macOS, Windows and CI runners are covered in docker-compose: command not found.
If it is installed but not found
command -v docker || ls -l /usr/bin/docker
hash -r # clear a stale shell lookup, then retryDocker Compose with restart: unless-stopped is also an easy way to keep a Discord or Telegram bot running: see bot hosting.
Docker wants a real kernel, so it runs best on KVM virtualisation, not container-based VPS types. Every VMHeaven KVM plan gives you full kernel control, which is what Docker (and nested containers) need. On an Ubuntu VPS, the install script above works as written.
Another tool missing, or a directory to add to PATH for good in bash, zsh and fish? See command not found: the three causes and the fix for every tool.
Frequently asked
Should I install Docker from apt or the official script?
Prefer Docker's official repository or convenience script. Distro packages are often several versions behind and may lack the Compose plugin.
Why does 'docker-compose' say command not found?
Compose v2 is a subcommand: run 'docker compose' with a space. The hyphenated binary is retired; install docker-compose-plugin if a script still needs the old name.
Why does docker need sudo?
Talking to the daemon requires root. Add your user to the 'docker' group to drop sudo, but note that membership is effectively root-level access.