Docker Command Not Found When Running on Mac

Docker Command Not Found When Running on Mac

I'm trying to run the below code as instructed in the docker-graphite-statsd:

docker run -d\
 --name graphite\
 --restart=always\
 -p 80:80\
 -p 2003-2004:2003-2004\
 -p 2023-2024:2023-2024\
 -p 8125:8125/udp\
 -p 8126:8126\
 graphiteapp/graphite-statsd

It gives this error:

$ sudo docker run -d --name graphite --restart=always -p 80:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/graphite-statsd
sudo: docker: command not found

This is on a Mac. I tried brew install docker but it made no difference.

How do I resolve this?

5

7 Answers

After installing docker using Homebrew, start the Docker daemon by searching for Docker in the Application folder in Finder and running it.

I had to run the following from terminal after doing the above: docker run -d -p 80:80 docker/getting-started

Now run "docker --version" from terminal and it should give the desired result.

Reference :

Run brew list which will show a list of all your installed Homebrew packages.

But it's highly recommended to install docker using below link on your mac :

1

I'm afraid you need to add docker command to your PATH manually. It can be done through profile file. As ZSH is now a default shell on MacOS, it would go to ~/.zprofile file:

# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio "
# Add Docker Desktop for Mac (docker)
export PATH="$PATH:/Applications/"

Homebrew's docker doesn't install /usr/local/bin/docker or the /Applications/Docker.app any more on 10.13.

You have to download the Docker Desktop for Mac application from the docker.com site above and install it.

2

If you successfully installed docker using the official package, the command should be available under /usr/local/bin/docker.

That directory might not yet be in your $PATH, so you could try adding it, run:

export PATH="/usr/local/bin:$PATH"

this adds /usr/local/bin to the front of your PATH.

credit:


Detais:

Check docker is not there:

docker
zsh: command not found: docker

Check what PATH is:

echo $PATH
/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.15~beta1/bin:/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin

Then add PATH (To set it for current shell and all processes started from current shell use export):

export PATH="/usr/local/bin:$PATH"

Check what I added to Path:

echo $PATH
/usr/local/bin:/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.15~beta1/bin:/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin

Seems that /usr/local/bin wasn't in my path. Probably odd? Seems odd to me...why isn't it there?

This command helped me:

/Applications/ --version

Check version after that:

docker --version

You can also install docker with following command on Mac:

brew install docker-machine docker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.