Docker Community Forums

Share and learn in the Docker community.

Installing docker with brew on Mac

What is the difference between brew install docker and Docker desktop from docker.com?

Open a command-line terminal and test that your installation works by running the simple Docker image, hello-world:

$ docker run hello-world

Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

Start a Dockerized web server. Like the hello-world image above, if the image is not found locally, Docker pulls it from Docker Hub.

$ docker run --detach --publish=80:80 --name=webserver nginx
In a web browser, go to http://localhost/ to view the nginx homepage. Because we specified the default HTTP port, it isn’t necessary to append :80 at the end of the URL.

nginx home page

Early beta releases used docker as the hostname to build the URL. Now, ports are exposed on the private IP addresses of the VM and forwarded to localhost with no other host name set.

View the details on the container while your web server is running (with docker container ls or docker ps):

$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56f433965490 nginx “nginx -g 'daemon off” About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 443/tcp webserver
Stop and remove containers and images with the following commands. Use the “all” flag (–all or -a) to view stopped containers.

docker container ls docker container stop webserver
docker container ls -a docker container rm webserver
docker image ls docker image rm nginx

@nsubrahm Docker Desktop for windows and mac have more than just the docker process. It has compose and other developer tools a native GUI app that shows up in your bar and, in general, quite a few nice features that are problematic on these systems like how file permissions are handled. I do not know exactly what is bundled in the brew package manager but I chose to have my development team work with the official downloads for mac and windows. I hope this helps.