Cloud Native 4 min read

Day 2: Install Docker Desktop and Launch Your First Container in 5 Minutes

This guide walks through installing Docker Desktop on macOS, verifying the installation, optionally configuring registry mirrors, then demonstrates running the hello‑world image, launching an interactive Ubuntu container, and starting NGINX in detached mode with port mapping, explaining each command and flag.

Tech Ocean
Tech Ocean
Tech Ocean
Day 2: Install Docker Desktop and Launch Your First Container in 5 Minutes
Day 1 covered the concepts; today we install Docker Desktop.

Docker Desktop can be installed on macOS either by downloading the installer from the official Docker documentation ( https://docs.docker.com/get-docker/) or via Homebrew with the command: brew install --cask docker After installation the Docker whale icon appears in Launchpad and a Docker icon shows in the menu bar; the first launch may prompt for a login (optional).

Verify the installation:

docker --version
# Docker version 29.4.0, build ...

docker compose version
# Docker Compose version v5.1.3

For faster image pulls in China, open Docker Desktop → Settings → Docker Engine and add a registry-mirrors array, for example:

{
  "registry-mirrors": [
    "https://docker.1ms.run",
    "https://docker.xuanyuan.me"
  ]
}

Click Apply & Restart to apply the mirrors.

Run Your First Container

docker run hello-world

The output shows:

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

What happens: docker run checks whether the hello‑world image exists locally.

If not, Docker pulls the image from Docker Hub.

Docker creates a container from the image and runs it.

Interactive Containers

To start a container and get a shell inside it:

# Create a container and enter bash
docker run -it ubuntu bash

# Exit the container
exit

Flags: -i: keep STDIN open (interactive mode). -t: allocate a pseudo‑TTY.

Note: after exit the container stops; use -d to run it detached.

Run NGINX in the Background

# Start NGINX detached and map ports
docker run -d -p 8080:80 nginx

# Verify it is running
docker ps

# Open a browser at http://localhost:8080

Flags: -d: run container in detached (background) mode. -p 8080:80: map host port 8080 to container port 80.

Day 2 Summary

Docker Desktop is the standard development tool. docker run hello-world = pull image + create container + run. -it for interactive mode, -d for background, -p for port mapping.

Next up on Day 3: the three essential image commands – pull, images, and rm.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIDockerNginxmacOScontainershello-worlddocker-desktop
Tech Ocean
Written by

Tech Ocean

Focused on AI programming, sharing ready-to-use development efficiency solutions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.