Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

The Mac terminal does not know the docker command

Errorzsh: command not found: docker

Short answer

The shell cannot find a docker binary in any folder on PATH. Docker Desktop for Mac puts symlinks in $HOME/.docker/bin and expects that folder on PATH. Check that the folder exists, add it to your shell profile, or switch the CLI location to /usr/local/bin in Docker Desktop settings.

  • Applies to macOS 15, Docker Desktop 4, zsh 5.9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See whether the binary exists and whether its folder is on PATH.

    ls -l ~/.docker/bin
    echo "$PATH" | tr ':' '\n' | grep -n docker
    ls /Applications/Docker.app
  2. 2Match what you see, then jump to its fix

    1. 1ls: /Applications/Docker.app: No such file or directoryDocker Desktop is not installedFix
    2. 2ls -l ~/.docker/bin shows docker, but the PATH listing has no .docker/bin line$HOME/.docker/bin is not on PATHFix
    3. 3Settings > Advanced shows the CLI tools in the system directory, and /usr/local/bin has no docker linkThe CLI location is set to the system folder but the symlinks are missingFix

What does the error look like?

  • zsh: command not found: docker
  • bash: docker: command not found

Cause 1 of 3

Docker Desktop is not installed

1Check

The Docker binaries live inside the app bundle. If there is no bundle, there is nothing to find.

ls /Applications/Docker.app/Contents/Resources/bin

2Fix

Install Docker Desktop for Mac from Docker's download page and open it once so it can finish setting up.

open -a Docker

3Verify

The command now resolves.

docker --version

Confirmed by docs.docker.com

Did this fix it?

Cause 2 of 3

$HOME/.docker/bin is not on PATH

1Check

Docker Desktop creates its symlinks in $HOME/.docker/bin and adds that folder to your PATH. A shell profile that sets PATH from scratch, or one that was never reloaded, removes it again.

grep -n "PATH" ~/.zshrc ~/.zprofile 2>/dev/null

2Fix

Add the folder back to PATH in your shell profile, then open a new terminal window.

echo 'export PATH="$HOME/.docker/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

3Verify

which finds the binary in the folder you added.

which docker

Confirmed by docs.docker.com

Did this fix it?

Cause 3 of 3

The CLI location is set to the system folder but the symlinks are missing

1Check

Docker Desktop can keep the symlinks in /usr/local/bin instead. If that folder is not writable by normal users, it needs authorisation before it creates them.

ls -l /usr/local/bin | grep -i docker

2Fix

Open Docker Desktop, go to Settings > Advanced, choose the location for the CLI tools, and approve the prompt if one appears. The user directory option avoids the prompt.

# Docker Desktop > Settings > Advanced > CLI tools location

3Verify

Open a new terminal and run the version command.

docker --version

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Keep PATH edits in one place, ~/.zshrc, and append to PATH instead of replacing it.
  • Open Docker Desktop once after every install or major upgrade.
  • Do not delete ~/.docker unless you plan to let Docker Desktop recreate it.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

The docker command cannot reach the Docker daemon

Cannot connect to the Docker daemon at unix:///Users/<user>/.docker/run/docker.sock. Is the docker daemon running?

This error means the docker client could not talk to a running daemon.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.