Skip to lesson

Installing Docker Desktop

Before ShopLite can run in a container, Docker must work on your computer. A wrong install shows up as confusing errors. What exactly gets installed, and how do you check it?

Installing Docker Desktop

Docker Desktop is the app that installs everything you need to run containers on Windows or macOS: the docker command, the Docker daemon, a small Linux VM and a dashboard.

Get the installer from Docker's official site (docs.docker.com, "Get Docker"), never from a third-party download site. Then open a new terminal and ask for the version.

Terminal
docker --version# Docker version 27.5.1, build 9f9e405

The steps are the same idea on every computer: download the installer, run it, accept the terms, open Docker Desktop and wait for Engine running. On Windows keep Use WSL 2 instead of Hyper-V ticked (run wsl --install in an administrator PowerShell first if WSL is missing). On a Mac pick the Apple silicon or Intel download to match the chip shown under Apple menu → About This Mac.

Docker Desktop is free for personal use, education and small businesses; large companies need a paid plan, so check the current terms on Docker's page.

Order of execution

Install and check Docker

Put the steps in the right order.

Linux is not covered step by step: install Docker Engine from Docker's own package repository for your distribution (docs.docker.com/engine/install), then add your user to the docker group as shown in the problems section below.

Client and daemon: docker version and docker info

The Docker daemon (dockerd, also called the engine) is the background program that pulls images and starts containers. The docker command is only a client that sends it requests.

docker version prints a Client block and a Server block. If the Server block is there, the client reached the daemon. docker info then lists the daemon's details.

Example 1 · docker version: client and server blocks

Runs in: a terminal with Docker Desktop running (Windows shown)

Terminal
docker version
Sample output
Client:
 Version:           27.5.1
 API version:       1.47
 Go version:        go1.22.11
 Git commit:        9f9e405
 Built:             Wed Jan 22 13:41:44 2025
 OS/Arch:           windows/amd64
 Context:           desktop-linux

Server: Docker Desktop 4.38.0 (181591)
 Engine:
  Version:          27.5.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.11
  Git commit:       4c9b3b0
  Built:            Wed Jan 22 13:41:24 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.25
 runc:
  Version:          1.1.12
 docker-init:
  Version:          0.19.0

What this code does

  • The Client block is the docker command: OS/Arch: windows/amd64 because it runs on Windows. The Server block is the daemon: linux/amd64 because it runs in the Linux VM.
  • containerd and runc are the lower-level tools the daemon uses to actually start containers. Your versions will differ; any Docker 27 or newer works for this course.

Example 2 · A tiny client and daemon in Java

DaemonDemo.javaJava
import com.sun.net.httpserver.HttpServer;import java.io.IOException;import java.io.OutputStream;import java.net.ConnectException;import java.net.InetSocketAddress;import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.nio.charset.StandardCharsets;
public class DaemonDemo {    static HttpClient client = HttpClient.newHttpClient();
    // The "client": like the docker command, it only sends requests    static void ping(int port) throws InterruptedException {        HttpRequest request = HttpRequest.newBuilder(URI.create("http://127.0.0.1:" + port + "/_ping")).build();        try {            HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());            System.out.println("client: GET /_ping -> " + response.body());        } catch (ConnectException e) {            System.out.println("client: Cannot connect to the daemon. Is the daemon running?");        } catch (IOException e) {            System.out.println("client: request failed: " + e.getClass().getSimpleName());        }    }
    public static void main(String[] args) throws IOException, InterruptedException {        // The "daemon": a server that does the real work        HttpServer daemon = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);        daemon.createContext("/_ping", exchange -> {            byte[] body = "OK".getBytes(StandardCharsets.UTF_8);            exchange.sendResponseHeaders(200, body.length);            try (OutputStream out = exchange.getResponseBody()) {                out.write(body);            }        });        daemon.start();        int port = daemon.getAddress().getPort();        System.out.println("daemon: started");
        ping(port);
        daemon.stop(0);        System.out.println("daemon: stopped");
        ping(port);    }}
Output
daemon: started
client: GET /_ping -> OK
daemon: stopped
client: Cannot connect to the daemon. Is the daemon running?

What this code does

  • The HttpServer plays the daemon and answers GET /_ping with OK; the real Docker API has the same /_ping endpoint. ping plays the docker command: it only sends a request.
  • After daemon.stop(0) the client still exists, but nobody answers, so the connection fails with ConnectException. That is exactly the "Cannot connect to the Docker daemon" situation.
  • The server uses port 0, so the OS picks a free port each run; the program prints no port numbers, so the output is the same every time.

Example 3 · docker info: what the daemon knows

Runs in: a terminal with Docker Desktop running (Windows shown)

Terminal
docker info
Sample output
Client:
 Version:    27.5.1
 Context:    desktop-linux
 ...
Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 27.5.1
 Storage Driver: overlayfs
 ...
 Kernel Version: 6.6.87.2-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 7.6GiB
 Name: docker-desktop
 Docker Root Dir: /var/lib/docker
 ...

What this code does

  • The output is long; ... marks lines left out here. On a fresh install, Containers and Images are 0.
  • Kernel Version shows the WSL 2 Linux kernel, and Total Memory is the memory of the Linux VM, not of your whole laptop. On a Mac you would see a Docker Desktop kernel and the Mac's VM memory.

The Docker client is the docker command you type. It only sends requests to the daemon through a socket or pipe (a local connection, like a phone line between two programs) and prints the answers.

On Windows and macOS the two OS/Arch lines differ: the client runs on your OS and the daemon runs in the Linux VM.

Predict the output

Read docker version

Say what the output tells you.

Round 1 of 2

What does this output tell you?

$ docker version
Client:
Version: 27.5.1
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

A tour of the Docker Desktop dashboard

The dashboard is Docker Desktop's window. It shows the same things the docker command shows, with buttons. It is handy for looking; for real work this course uses the terminal, because commands can be copied, scripted and run in CI.

Terminal
# Containers tab  (running and stopped containers)docker ps -a# Images tab      (images on this computer)docker images# Volumes tab     (stored data, for example a database)docker volume ls
  • Containers: start, stop, delete, see logs and open a terminal inside a container.
  • Images: local images, their sizes and tags; pull or delete them.
  • Volumes: data that survives when containers are deleted (the Docker Essentials module).
  • Settings → Resources: CPU, memory and disk for the Linux VM. With the WSL 2 backend, memory and CPU are set by Windows in a .wslconfig file instead.

Common install problems and their fixes

The docker group is a Linux group whose members may use the Docker daemon without sudo. That access is as powerful as root, so add only your own user.

Almost every install problem is one of a few known errors, and the error text tells you which one. The code below maps an error message to its fix.

Example 4 · The three most common connection errors

Runs in: a terminal with the Docker CLI installed

Terminal
# Windows: Docker Desktop is not starteddocker ps# Linux: the docker service is stoppeddocker ps# Linux: your user is not in the docker groupdocker ps
Sample output
error during connect: Get "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.47/containers/json": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.47/containers/json": dial unix /var/run/docker.sock: connect: permission denied

What this code does

  • Windows: the client looks for Docker Desktop's named pipe dockerDesktopLinuxEngine and it does not exist yet, so Docker Desktop is not running. Start it and wait for Engine running.
  • Linux: "Cannot connect" means the service is stopped (sudo systemctl start docker); "permission denied" means the service runs but your user is not in the docker group.
  • The v1.47 in the URLs is the API version of your client, so it will differ with your Docker version.

Example 5 · Matching an error message to its fix

DiagnoseDemo.javaJava
import java.util.LinkedHashMap;import java.util.List;import java.util.Map;
public class DiagnoseDemo {    static final Map<String, String> FIXES = new LinkedHashMap<>();
    static {        FIXES.put("permission denied", "Linux: add yourself to the docker group, then log out and in");        FIXES.put("Cannot connect to the Docker daemon", "Start the daemon (Docker Desktop, or systemctl start docker)");        FIXES.put("dockerDesktopLinuxEngine", "Windows: start Docker Desktop and wait for Engine running");        FIXES.put("Virtualization support not detected", "Turn on virtualization (VT-x / AMD-V) in BIOS/UEFI");        FIXES.put("WSL", "Windows: run wsl --update in an admin PowerShell, then restart");    }
    static String diagnose(String error) {        for (Map.Entry<String, String> e : FIXES.entrySet()) {            if (error.contains(e.getKey())) {                return e.getValue();            }        }        return "Unknown error: copy the exact message into the Docker docs search";    }
    public static void main(String[] args) {        List<String> errors = List.of(                "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?",                "permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock",                "open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.",                "WSL update failed",                "no space left on device");        for (int i = 0; i < errors.size(); i++) {            System.out.println("Error " + (i + 1) + " -> " + diagnose(errors.get(i)));        }    }}
Output
Error 1 -> Start the daemon (Docker Desktop, or systemctl start docker)
Error 2 -> Linux: add yourself to the docker group, then log out and in
Error 3 -> Windows: start Docker Desktop and wait for Engine running
Error 4 -> Windows: run wsl --update in an admin PowerShell, then restart
Error 5 -> Unknown error: copy the exact message into the Docker docs search

What this code does

  • A LinkedHashMap keeps the rules in insertion order, and diagnose returns the first rule whose key appears in the message.
  • Order matters: the permission-denied message also mentions the daemon socket, so the more specific "permission denied" rule is checked first.
  • Unknown errors get a safe default: search the exact message, which is the right habit for any tool.

Cannot connect to the Docker daemon means the client works but nothing is answering. permission denied ... docker.sock on Linux means the daemon runs, but your user may not talk to it. Install-time problems come from the VM layer: virtualization disabled in the BIOS/UEFI (the computer's start-up settings) or an old WSL.

The fixes:

  • Daemon not reachable: start Docker Desktop and wait for Engine running; on Linux sudo systemctl start docker.
  • Permission denied on Linux: sudo usermod -aG docker $USER, then log out and in (or run newgrp docker).
  • Virtualization not detected: turn on Intel VT-x or AMD-V (SVM) in BIOS/UEFI; Task Manager → Performance → CPU shows "Virtualization: Enabled".
  • WSL errors: run wsl --update in an administrator PowerShell, then restart Docker Desktop.
Members of the docker group can control the daemon, which is as powerful as root access. Add only your own user on your own machine.

Alternatives to Docker Desktop

Other tools run the same images and accept nearly the same commands. You do not need them for this course; they are worth knowing by name.

  • Podman: a daemonless container engine from Red Hat; podman run works like docker run.
  • Rancher Desktop: a free desktop app with a Linux VM, the docker command (via moby) and Kubernetes.
  • colima: a small command-line tool for macOS (and Linux) that starts a Linux VM for the docker command.

Next step

Check your understanding

11 quick questions