Skip to Content
Installation

Install Docker

Run container-based systems on Windows and Linux Mint, with the full installation and the most common pitfalls.

Last reviewed:

What you get out of this

When you are done, you can start a complete program, with a database and everything, by typing one line in a terminal window. You can try Odoo, WordPress, Nextcloud or n8n on the company computer without installing anything that stays behind and clutters things up afterward. If something goes wrong, you delete the container and start over. The computer notices nothing.

Docker is also a technical skill you benefit from long after this installation. Almost every development job in Sweden uses containers in one way or another, and you gain that understanding in an afternoon.

The Docker logo with a blue whale

What you need before you start

  • A computer with an updated 64-bit version of Windows 10 or 11, or Linux Mint 21 or later. Docker Desktop requires Windows to be updated with its latest major updates, and Windows 10 has also left Microsoft's regular support, so Windows 11 is the safer choice on a new computer.
  • Administrator rights on the computer. On a shared or managed computer you rarely have them, so plan to run this on your own computer.
  • At least 8 GB of memory if you are going to run anything bigger than a test example. Docker itself takes little, but a database and a web server next to each other want space.
  • About 10 GB free on the disk. The images that are downloaded are large.
  • Patience with a black window. You will be typing commands, and every command is explained here.

Time and difficulty level

The installation takes twenty minutes on Linux Mint and a little longer on Windows, where the computer has to be restarted once. Allow an afternoon for the whole guide if you also want to understand what you are doing. The difficulty level is in the middle: you type commands, but you do not administer any server and cannot destroy anything that cannot be deleted.

What a container actually is

A program rarely needs only itself. It needs the right version of Python or PHP, a database, a couple of libraries and a handful of settings. That is why installations cause trouble: your computer has version 3.10 and the program wanted 3.12.

A container is the program plus all of that, packaged in a single bundle. The bundle is called an image, and when you start an image it becomes a container. The same image gives the same result on your computer, on a colleague's computer and on the server. That is the whole point.

A container is not a virtual machine. It shares the operating system kernel with the computer instead of running its own operating system, which makes it fast to start and easy to throw away. The container has its own file system, and everything written inside it disappears when it is deleted. If something needs to be saved, you put it in a volume, and we will come back to that.

Windows: Docker Desktop

On Windows, Docker runs via WSL2, Windows Subsystem for Linux, which is a small Linux that Microsoft has built into Windows. Docker Desktop handles it for you.

  1. Check that virtualization is turned on. Open Task Manager, go to the Performance tab and click CPU. If it says Virtualization: Enabled, everything is fine. If it says disabled, you must turn it on in the computer's BIOS, and then you need to ask someone who has done it before for help.
  2. Open PowerShell as administrator and run wsl --install. The command installs WSL2 and an Ubuntu environment. Restart the computer when it is done.
  3. Download Docker Desktop from docker.com and run the installation file. Leave the box about WSL2 checked.
  4. Start Docker Desktop. The first start takes a minute or two. At the bottom left of the window, a small whale should light up green.
  5. Open PowerShell and type docker --version. If you get a version number back, you are done.

The license is worth thirty seconds. Docker Desktop is free for private individuals, for education and for companies with fewer than 250 employees and under ten million dollars in revenue. Most smaller companies are well within that. So you do not need to pay, but you should know why.

Linux Mint: Docker Engine

On Linux Mint you do not need Docker Desktop. There Docker runs directly on the system, which is both simpler and faster. There is a package called docker.io in Mint's own repositories, but it is often several versions behind and lacks the docker compose command. Add Docker's own repository instead.

Open Terminal and run the commands one at a time. First keys and preparations:

sudo apt update
sudo apt install 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

Now comes the line where most Mint installations go wrong. Docker's repository is built for Ubuntu, and Linux Mint has its own codename, for example xia or wilma. If you enter Mint's codename, Docker finds nothing and apt responds that the repository does not exist. The file /etc/os-release therefore also contains the line UBUNTU_CODENAME, which tells you which Ubuntu version your Mint is based on. That is the one you should use:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$UBUNTU_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

If you want to check that it turned out right before you continue, run cat /etc/apt/sources.list.d/docker.list and check that there is an Ubuntu codename in the line, for example noble or jammy. Then you install:

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Finally: add your user to the docker group so that you do not have to write sudo in front of every command.

sudo usermod -aG docker $USER

Log out and back in again, otherwise the group does not apply. Then test with docker --version and docker compose version. If you get two version numbers, you are up and running.

Adding a user to the docker group in practice gives the same permissions as root on the computer. On your own computer that is reasonable. On a computer that several people use, you should think it over once more.

First container

The same commands now work in PowerShell on Windows and in Terminal on Mint. Start with the smallest one:

docker run hello-world

Docker looks for the image locally, does not find it, downloads it and runs it. You get a greeting that explains what just happened. Then try something you can see in the browser:

docker run -d -p 8080:80 --name min-webb nginx

The flags mean three things. -d runs the container in the background so that you get the prompt back. -p 8080:80 connects port 8080 on your computer to port 80 inside the container, where the web server listens. --name min-webb gives the container a name so that you avoid dealing with long id numbers.

Open http://localhost:8080 in the browser. There it says that Nginx works. With docker ps you see what is running, and with docker stop min-webb and docker rm min-webb you shut it down and delete it.

When a service needs several parts

Most real systems consist of more than one container. Nextcloud wants a database next to it, and so does WordPress. Starting them one by one with long commands quickly becomes unmanageable, and that is why docker compose exists: a text file that describes all the parts, and a command that starts them together.

The file is called compose.yaml and sits in its own folder. A small example:

services:
  webb:
    image: nginx
    ports:
      - "8080:80"
    restart: unless-stopped

If you are in the folder, you run docker compose up -d to start and docker compose down to shut down. The line restart: unless-stopped makes the container start again after a computer restart, which you want for everything that should be running for real.

One more thing, and it is important: everything the container writes in its own file system disappears when the container is deleted. Databases and uploaded files should therefore be in a volume, a storage space that Docker keeps separate. In a compose file it looks like this under the service:

    volumes:
      - min_data:/var/lib/data

and at the bottom of the file, without indentation:

volumes:
  min_data:

The guides for Nextcloud, n8n and Vaultwarden all use that pattern, so you will recognize it.

Clean up after yourselves

Images and volumes stay until you remove them, and a computer with ten tested systems starts to run out of disk. docker ps -a shows all containers, including stopped ones. docker images shows downloaded images. The command docker system prune clears what is not used by any container right now.

Be careful with docker system prune -a --volumes anyway. It removes volumes that are no longer used by any container, for example a forgotten anonymous volume from a deleted container. Named volumes that are still connected to a container, like min_data in the example above, are left alone. Only run it when you are sure about what is actually no longer needed.

How to know it worked

  • docker --version and docker compose version respond with version numbers.
  • docker run hello-world prints the greeting text.
  • The Nginx container is visible at http://localhost:8080.
  • On Mint, the commands work without sudo.
  • docker ps lists what is running, and docker stop shuts it down.

If something goes wrong

Windows: "Docker Desktop starting" hangs. Open PowerShell and run wsl --update, then restart the computer. If that does not help, uninstall Docker Desktop, restart and install again. It sounds crude and it usually works.

Windows: error message about virtualization. Then virtualization is turned off in the BIOS. The setting is often called Intel VT-x, AMD-V or SVM Mode.

Mint: "permission denied while trying to connect to the Docker daemon socket". You have not logged out and back in after usermod. Log out, log in, try again.

Mint: apt cannot find the packages. Almost always the codename. Check /etc/apt/sources.list.d/docker.list and make sure an Ubuntu codename is there, not Mint's own.

"port is already allocated". Something else is using the port. Change the left number in -p, for example -p 8081:80, and open the address with the new number.

The download takes forever. Images are hundreds of megabytes. On a slow connection it can take a while, and there is nothing wrong.

What you do next

Now that Docker is in place, you can run real systems. Install Nextcloud gives the company its own file space. Install Vaultwarden solves the passwords, which you will need. Install n8n automates what would otherwise be done by hand every week. And Install Odoo sets up a complete business system.

Take one at a time, and start with the one that solves a problem you actually have.

Cart

Loading