Docker is a platform for running and managing containers. On Ubuntu 24.04 and in WSL, installation is done through the official Docker repository. Docker Compose is now built into the Docker package and runs as docker compose, without a separate installation.

📋 Requirements

  • Ubuntu 24.04 (native or WSL)
  • Permissions sudo
  • Internet access

Step 1. System Update

sudo apt update && sudo apt upgrade -y

Step 2. Installing Dependencies

sudo apt install -y ca-certificates curl gnupg lsb-release

Step 3. Adding the GPG Key and Docker Repository

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Adding the repository:

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

Step 4. Installing Docker Engine

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

Step 5. Checking Installation

Check the version:

docker --version
docker compose version

Test run:

sudo docker run hello-world

Step 6. Using Docker Without sudo

By default, Docker requires sudo. To run it as a regular user:

sudo groupadd docker   # if the group already exists, there will be an error — this is normal
sudo usermod -aG docker $USER
newgrp docker

Check:

docker run hello-world

Step 7. Docker in WSL

  • It is recommended to install Docker inside WSL only when using WSL2 and a full Linux kernel.
  • You can also install Docker Desktop on Windows and connect WSL to it.
  • To check that Docker is working inside WSL:
docker ps

Common Errors and Solutions

Error: permission denied when running docker

You forgot to add the user to the docker group. Repeat:

sudo usermod -aG docker $USER
newgrp docker
Error: docker: command not found

Make sure that the packages docker-ce and docker-ce-cli are installed and that they do not conflict with older versions.

sudo apt remove -y docker docker-engine docker.io containerd runc
WSL: very slow Docker

Use WSL2 (in PowerShell on Windows):

wsl --set-version Ubuntu-24.04 2

And keep projects in the Linux path (~/project), not in /mnt/c.


Useful Docker Commands

# List of containers
docker ps -a

# Run a container
docker run -d -p 8080:80 nginx

# List of images
docker images

# Remove a container
docker rm -f CONTAINER_ID

# Remove an image
docker rmi IMAGE_ID

Conclusion 🎉

You now have Docker and Docker Compose installed on Ubuntu 24.04 and in WSL. You can run containers, build images, and use docker compose for multi-container projects.