> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Install Docker on Ubuntu, Debian and AlmaLinux

> Install Docker on Ubuntu 24.04 from Docker's official apt repository: add the GPG key and repo, install docker-ce and the Compose plugin, then run hello-world.

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`.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 10 minutes | Ubuntu 22.04 / 24.04, Debian 12 / 13, AlmaLinux / Rocky 9 / 10 | Root or sudo access, a 64-bit server |

## Before you start

* Log in over SSH as root or as a [sudo user](https://help.freakhosting.com/portals/other/how-to-create-a-sudo-user-on-linux.md). 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](https://docs.docker.com/engine/install/).

## How to install Docker

> [tab] Ubuntu
>
> **1. Remove conflicting packages**
>
> Remove unofficial packages such as `docker.io` or `podman-docker` if they are installed:
>
> ```bash theme={null}
> sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)
> ```
>
> If none are installed, apt tells you there is nothing to remove.
>
> **2. Add Docker's GPG key**
>
> ```bash theme={null}
> 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
> ```
>
> **3. Add the Docker repository**
>
> ```bash theme={null}
> sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
> Types: deb
> URIs: https://download.docker.com/linux/ubuntu
> Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
> Components: stable
> Architectures: $(dpkg --print-architecture)
> Signed-By: /etc/apt/keyrings/docker.asc
> EOF
> sudo apt update
> ```
>
> **4. Install Docker Engine and Compose**
>
> ```bash theme={null}
> sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
> ```
>
> On Ubuntu and Debian the Docker service starts automatically.

> [tab] Debian
>
> **1. Remove conflicting packages**
>
> ```bash theme={null}
> sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-doc docker-buildx podman-docker containerd runc | cut -f1)
> ```
>
> **2. Add Docker's GPG key**
>
> ```bash theme={null}
> 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/debian/gpg -o /etc/apt/keyrings/docker.asc
> sudo chmod a+r /etc/apt/keyrings/docker.asc
> ```
>
> **3. Add the Docker repository**
>
> ```bash theme={null}
> sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
> Types: deb
> URIs: https://download.docker.com/linux/debian
> Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
> Components: stable
> Architectures: $(dpkg --print-architecture)
> Signed-By: /etc/apt/keyrings/docker.asc
> EOF
> sudo apt update
> ```
>
> **4. Install Docker Engine and Compose**
>
> ```bash theme={null}
> sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
> ```

> [tab] AlmaLinux / Rocky
>
> Docker publishes packages for RHEL 8, 9 and 10. AlmaLinux and Rocky Linux are RHEL-compatible, but Docker doesn't list them as officially supported.
>
> **1. Remove Podman and old packages**
>
> ```bash theme={null}
> sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc
> ```
>
> **2. Add the Docker repository**
>
> ```bash theme={null}
> sudo dnf -y install dnf-plugins-core
> sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
> ```
>
> **3. Install Docker Engine and Compose**
>
> ```bash theme={null}
> sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
> ```
>
> If dnf asks you to accept a GPG key, check that the fingerprint is `060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35`.
>
> **4. Start Docker and enable it at boot**
>
> ```bash theme={null}
> sudo systemctl enable --now docker
> ```

## How to check it worked

```bash theme={null}
sudo docker run hello-world
docker --version
docker compose version
```

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

```text theme={null}
Docker version 29.9.2, build a82e528
Docker Compose version v5.6.1
```

## How to run Docker without sudo

The install creates a `docker` group but adds nobody to it. Add your user (for example `alex`):

```bash theme={null}
sudo usermod -aG docker alex
```

Log out and back in, then run `docker ps` without `sudo`.

> [!WARNING]
>
> 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:

```json theme={null}
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}
```

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

> [!WARNING]
>
> 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](https://help.freakhosting.com/portals/other/how-to-set-up-nginx-as-a-reverse-proxy.md) in front of it. See [Docker's packet filtering docs](https://docs.docker.com/engine/network/packet-filtering-firewalls/).

## 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.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Docker Compose tutorial](https://help.freakhosting.com/portals/other/how-to-use-docker-compose.md)
>
> Run multi-container apps from one file.

> [card] [Docker commands cheat sheet](https://help.freakhosting.com/portals/other/essential-docker-commands.md)
>
> The commands you use every day.

> [card] [Install Portainer](https://help.freakhosting.com/portals/other/how-to-install-portainer.md)
>
> Manage Docker in your browser.

> [card] [Clean up Docker disk space](https://help.freakhosting.com/portals/other/how-to-clean-up-docker-disk-space.md)
>
> Free space with docker system prune.

> [card] [Set up a firewall with UFW](https://help.freakhosting.com/portals/other/how-to-set-up-a-firewall-with-ufw.md)
>
> Allow only the ports you need.

***

> [!NOTE]
>
> **Checked against the official [Docker Engine install documentation](https://docs.docker.com/engine/install/)** 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.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.