Skip to main content
To install Docker on Ubuntu 24.04, add Docker’s official apt repository and GPG key, then run sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin. Test it with sudo docker run hello-world. On AlmaLinux or Rocky Linux, add Docker’s repository with dnf config-manager and install the same packages with dnf.

Before you start

  • Log in over SSH as root or as a sudo user. Root users can leave out sudo.
  • Docker Engine is the program that runs containers. A container is an app packaged with everything it needs, isolated from the rest of the server.
  • Don’t install Docker from the Ubuntu snap store. Several apps (Portainer, Nextcloud AIO, Coolify) don’t support snap Docker.
  • Use a supported release. Docker supports Ubuntu 22.04 and 24.04 LTS (and newer), Debian 12 and 13, and RHEL 8, 9 and 10. See Docker’s install docs.

How to install Docker

1

Remove conflicting packages

Remove unofficial packages such as docker.io or podman-docker if they are installed:
If none are installed, apt tells you there is nothing to remove.
2

Add Docker's GPG key

3

Add the Docker repository

4

Install Docker Engine and Compose

On Ubuntu and Debian the Docker service starts automatically.

How to check it worked

hello-world prints Hello from Docker! and exits. The version commands print lines such as:

How to run Docker without sudo

The install creates a docker group but adds nobody to it. Add your user (for example alex):
Log out and back in, then run docker ps without sudo.
Members of the docker group have root-level access to the server. Only add users you would give full sudo rights.

How to stop container logs filling your disk

By default Docker keeps container logs forever. Create /etc/docker/daemon.json with log rotation:
Restart Docker with sudo systemctl restart docker. This applies to new containers only, so recreate existing ones to pick it up.

Docker and your firewall

Ports you publish with -p 8080:80 bypass ufw and firewalld rules. Docker inserts its own rules before your firewall sees the traffic. To keep a container private, publish it on localhost only (-p 127.0.0.1:8080:80) and put a reverse proxy in front of it. See Docker’s packet filtering docs.

Frequently asked questions

Should I use the get.docker.com script?

Docker’s convenience script works, but Docker recommends it only for testing and development. Use the repository method above on a production server.

What is the difference between docker.io and docker-ce?

docker.io is the package built by Ubuntu and Debian. docker-ce comes from Docker’s own repository and is updated sooner. Don’t install both.

How do I update Docker?

Docker updates with your normal system updates: sudo apt update && sudo apt upgrade or sudo dnf upgrade. Containers stop while the Docker service restarts. Containers with a restart policy such as unless-stopped start again on their own.

Does Docker work on Alpine or Arch Linux?

Yes, both ship Docker in their own repositories, but Docker’s install guide doesn’t cover them. Follow your distribution’s documentation.

VPS and dedicated server guides

Every guide in this section.

Docker Compose tutorial

Run multi-container apps from one file.

Docker commands cheat sheet

The commands you use every day.

Install Portainer

Manage Docker in your browser.

Clean up Docker disk space

Free space with docker system prune.

Set up a firewall with UFW

Allow only the ports you need.

Checked against the official Docker Engine install documentation on 4 November 2026; package names, daemon.json and post-install commands tested on Ubuntu 24.04 LTS with Docker Engine 29.9.2. Commands can differ on other distributions or releases.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026