Docker Cross-PlatformInstallation

Article & Tutorial

Install Docker on Ubuntu, Windows, and macOS: Complete Beginner Guide

Install Docker on Ubuntu, Windows, and macOS with verification steps, a first container test, common setup fixes, permissions guidance, and safe defaults.

Docker installation across Ubuntu Windows and macOS
Docker installation across Ubuntu Windows and macOS
Contents

Install Docker on Ubuntu, Windows, and macOS

This beginner guide explains how to install Docker, verify the installation, run your first container, and fix common setup issues.

Before you install Docker

Docker can be installed in different ways depending on your operating system. On Linux servers, Docker Engine is common. On Windows and macOS, Docker Desktop is commonly used because it includes the Docker CLI, Docker Engine integration, Compose support, and a desktop interface.

Install Docker on Ubuntu

For Ubuntu, the recommended production approach is to follow Docker’s official repository-based installation. Below is a simplified learning workflow. Always compare commands with the official Docker documentation before using in production.

Install the prerequisite packages, add Docker’s signed package repository using the current official instructions, refresh the package index, and install Docker Engine, the command-line client, containerd, Buildx, and the Compose plug-in.

Verify Docker on Ubuntu

docker --version sudo docker run hello-world

Run Docker without sudo

Add your current account to the docker group with the usermod command newgrp docker docker run hello-world

Install Docker on Windows

  1. Install Docker Desktop for Windows from Docker’s official site.
  2. Enable WSL 2 if Docker Desktop asks for it.
  3. Restart your system if required.
  4. Open PowerShell and run verification commands.

docker --version docker compose version docker run hello-world

Install Docker on macOS

  1. Download Docker Desktop for Mac from Docker’s official site.
  2. Choose the correct Apple Silicon or Intel version.
  3. Drag Docker to Applications.
  4. Start Docker Desktop and wait until Docker is running.

docker --version docker run hello-world

First useful container

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

Open http://localhost:8080 in your browser, or http://SERVER_IP:8080 when testing on a remote Ubuntu server with intentionally permitted network access. Stop and remove the container afterward:

docker stop web docker rm web

Common errors

  • Error — Meaning — Fix
  • Cannot connect to Docker daemon — Docker service is not running — Start Docker service or Docker Desktop.
  • Permission denied — User cannot access Docker daemon — Use sudo or add user to docker group carefully.
  • Port already allocated — Host port is already used — Use another port like 8081:80.

Best practices

  • Use official installation documentation for production systems.
  • Verify installation with hello-world .
  • Keep Docker updated.
  • Do not run random images from untrusted sources.
  • Understand Docker group permissions on Linux.

Backlinks

  • Docker Learning Path
  • What is Docker?

Official references

  • Install Docker Engine on Ubuntu
  • Install Docker Desktop on Windows
  • Install Docker Desktop on Mac

Ubuntu: install Docker Engine from the official apt repository

For supported 64-bit Ubuntu releases, Docker recommends installing from its apt repository. Review the official prerequisites and conflicting-package guidance first. Do not run these commands on a host with existing Docker workloads until you have inspected how containers and network rules will be affected. This is an illustrative installation workflow, not a claim of a test on your machine.

ubuntu-docker-install.sh
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl status docker --no-pager
sudo docker run --rm hello-world

Expected result: docker --version shows an installed CLI; docker compose version reports the Compose plugin; the hello-world container prints a success message and exits. If Docker fails to start, inspect sudo systemctl status docker and sudo journalctl -u docker --no-pager -n 100 before changing firewall rules.

Windows and macOS prerequisites

PlatformRecommended setupVerification
Windows 10/11 supported editionsInstall Docker Desktop and use supported WSL 2 or Hyper-V backend; ensure virtualization and the required OS build are availableOpen Docker Desktop; run docker version, docker compose version and docker run --rm hello-world in PowerShell
macOS Apple silicon or IntelInstall Docker Desktop for the correct chip and supported macOS version; allow needed permissionsLaunch Docker Desktop and run docker version and docker run --rm hello-world in Terminal
Ubuntu serverInstall Docker Engine packages from the official repository and review daemon securityRun sudo systemctl status docker and sudo docker run --rm hello-world

Permissions and networking safety

Members of the docker group effectively have root-level control on the host through the Docker socket. Prefer sudo docker or rootless Docker where suitable rather than casually granting access. Publishing -p 8080:80 binds the host port broadly by default; for local-only testing, prefer -p 127.0.0.1:8080:80. Docker-published ports may bypass some host firewall expectations, including ufw; review the official packet-filtering guidance before exposing a container.

safe-first-container.sh
docker run -d --name melochip-nginx-demo -p 127.0.0.1:8080:80 nginx:stable
# From the same machine, open http://localhost:8080
# Remove only the demo container when finished:
docker stop melochip-nginx-demo
docker rm melochip-nginx-demo

Troubleshooting by symptom

SymptomCheckLikely action
Cannot connect to Docker daemondocker version; systemctl status docker (Linux) or Docker Desktop statusStart the daemon or Desktop; verify your selected Docker context
Permission denied on /var/run/docker.sockid; ls -l /var/run/docker.sockUse sudo or consider rootless mode; evaluate docker-group privilege
Port 8080 already allocatedss -ltn (Linux) or netstat (platform-specific)Choose another local port or stop the conflicting service
WSL 2 backend unavailable on Windowswsl --status in PowerShell; check virtualization supportUpdate or enable WSL and meet the Docker Desktop Windows prerequisites

Official documentation: https://docs.docker.com/engine/install/ubuntu/ , https://docs.docker.com/desktop/setup/install/windows-install/ and https://docs.docker.com/desktop/setup/install/mac-install/ . Related Melochip guide: https://melochip.com/posts/what-is-docker-complete-beginner-guide-with-examples .

Official Docker installation instructions for Ubuntu

Melochip Docker fundamentals

Did this help?

Yes No

Join the discussion

0 Comments

Ask questions, add context, or share what worked.

Sign in to join the discussion

No comments yet. Start the discussion.

More from Melochip Editorial

Related articles

Stay in the loop. Get new Melochip articles

Receive Melochip article updates when new articles are available. Explicit opt-in only.

No pre-checked boxes. Unsubscribe support is part of the subscriber foundation.