Aflorzy logo

Install Docker on any Operating System

Published Nov 2, 2024

Updated Apr 25, 2025

Learn how to get Docker running on your system so you can start working with containers!

Written by Andrew Flores

dockertutorial

Docker Desktop (Windows/Mac)

Docker desktop provides you with an interactive GUI for spinning up new containers and managing existing ones. Installing Docker Desktop is a simple and reliable method that is supported on both Windows and Mac operating systems*.

Note that the Docker daemon is also installed during this process which enables you to use the command line to run docker commands directly from the terminal.

  1. Download the correct .exe installer from the official downloads page

  2. Double-click the downloaded file and follow the installation steps.

  3. Find the new app in your Start Menu or task bar and open it up!

  4. See below for Next Steps!

While the Docker Desktop GUI provides a nice interface for starting new containers, it is limited in comparison with other free container management software such as Portainer and Dockge. I recommend that you also start getting familiar with using the command line to interact with Docker instead of relying on the abstractions that Docker Desktop provides.


* Some linux distributions also support the installation of Docker Desktop but am opting to not elaborate on those methods here as desktop environments can vary and many linux installations are headless and would not benefit from the full Docker Desktop installation.

Linux

There are several accepted ways to install docker on Linux and the methods can vary depending on the distribution/flavor of Linux you have.

Debian/Ubuntu

docker.io

Terminal window
sudo apt install docker.io
sudo apt install docker-compose

These packages will get you up and running with Docker as quickly as possible! After installing them, you’ll be able to run both docker and docker-compose commands from your terminal. Although they work quickly, Docker’s official website recommends a more thorough approach that is outlined in the next section.

apt

Disclaimer: This section is copied verbatim from the official Docker Ubuntu guide. You can copy and paste the entire block of commands directly into your terminal or run each line individually.

  1. Set up Docker’s apt repository
Terminal window
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get 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
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
  1. Install the Docker packages
Terminal window
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  1. Verify that the Docker Engine installation is successful by running the hello-world image.
Terminal window
sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.

Other Linux distributions

Post Install Steps

There are just a couple more steps to take before you Docker installation is working hassle-free! These are based on the steps outlined in the official docs.

Run Docker Commands as a Non-Root User

By default, your user will not have permission to run docker commands. You can temporarily solve this by prefixing the commands with sudo. However, this can be tedious so it is a common practice to add your user to the docker permissions group. The commands below will handle this.

Terminal window
sudo groupadd docker # Create the docker user group if it doesn't exist
sudo usermod -aG docker $USER # Add your user to the group. Note that $USER is referencing a built-in variable and you can leave it as-is
newgrp docker # Refresh the group permissions
# Test that it's working!
docker run hello-world

Automatically Start Docker on Boot

Finally, Docker may not start up automatically when your OS boots so you can run these commands to ensure the dependent services are enabled.

Terminal window
sudo systemctl enable docker.service
sudo systemctl enable containerd.service

What now?

Congratulations! The world of Docker is now available at your fingertips. Time to start finding some containers to run! Check out the next post in this collection, Getting Started with Docker, for tips on how to spin-up your first useful container.

Thanks for reading!