Docker lets you run applications in isolated containers — think lightweight VMs that start in seconds. This guide gets you from zero to running your first container.

Installation

brew install --cask docker

Launch Docker Desktop from Applications. The whale icon in your menu bar means it’s running. Verify:

docker --version
docker run hello-world

If you see “Hello from Docker!”, you’re ready.

Your First Container

Run a web server in one command:

docker run -d -p 8080:80 --name my-nginx nginx

Now open http://localhost:8080 — you should see the Nginx welcome page.

Breaking down the command:

  • -d — run in background (detached)
  • -p 8080:80 — map port 8080 on your machine to port 80 in the container
  • --name my-nginx — give the container a name
  • nginx — the image to run

Useful Commands

CommandWhat it does
docker psList running containers
docker ps -aList all containers
docker stop my-nginxStop a container
docker rm my-nginxRemove a container
docker imagesList downloaded images
docker logs my-nginxView container logs
docker exec -it my-nginx bashOpen a shell in the container

Docker Compose

For multi-container apps, Docker Compose uses a YAML file. Create compose.yml:

services:
  web:
    image: nginx
    ports:
      - "8080:80"
  db:
    image: postgres
    environment:
      POSTGRES_PASSWORD: example

Run with:

docker compose up -d

Docker Desktop includes Compose, Kubernetes, and a dashboard for managing everything visually.