Skip to content

How to Install Docker on RHEL and Ubuntu

Last validated:
View as Markdown

WHAT TO EXPECT

In this section, users will learn how to install Docker Engine for either RHEL or Ubuntu. For more detailed instructions, see their respective pages on the Docker documentation site:

PLEASE NOTE

For virtual machines it is NOT recommended to install Docker Desktop. Use Docker Engine instead.

For bare metal machines that will run swXtch.io software it is still recommended to use Docker Engine, unless there is a full desktop environment with a display server like X11 or Wayland.

PLEASE NOTE

There are two ways to get Docker. The official (Docker-CE or Community Edition), maintained and hosted by Docker Inc. and Docker.io, maintained and distributed by the OS (RHEL, Ubuntu, etc).

The swXtch.io installers use Docker CE: installing with the --auto_deps argument installs Docker CE, and an existing docker.io is migrated to Docker CE.

Rootful Podman is also supported as the container runtime (--container-runtime podman; with --auto_deps the installer installs Podman from the OS repositories): for cloudSwXtch and OMNI on Ubuntu 22.04/24.04 and RHEL/Rocky/AlmaLinux 9/10, and for the swXtchBridge on Ubuntu 22.04/24.04, RHEL/Rocky/AlmaLinux 8/9/10 and Debian 12. Docker remains the default. Rootless Podman is not supported.

Installing Docker-ce on RHEL

  1. Run the following command to prepare the repositories for the Docker install:

    sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
    cat /etc/yum.repos.d/docker-ce.repo
    sudo sed -i "s/\$releasever/$(rpm -E %rhel)/g" /etc/yum.repos.d/docker-ce.repo
    cat /etc/yum.repos.d/docker-ce.repo
    sudo dnf -y install dnf-plugins-core
    
  2. Install Docker-ce:

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

    On RHEL, Rocky Linux and AlmaLinux 10, Docker also needs the iptables modules in kernel-modules-extra, which cloud images do not include. Without them Docker does not start (Extension addrtype revision 0 not supported, missing kernel module?). Install the package for the running kernel, and for any newer kernel the host will boot:

    sudo dnf install kernel-modules-extra-$(uname -r)
    

    The swXtch.io installers add it when they install Docker with --auto_deps. Podman does not need it.

  3. Continue on to Enabling Docker.

Installing Docker-ce on Ubuntu

  1. Install Docker:

    curl https://get.docker.com/ > dockerinstall && chmod 777 dockerinstall && sudo ./dockerinstall
    
  2. Continue on to Enabling Docker.

Enabling Docker

After installing Docker-ce, run the following commands to enable it on your machine:

sudo usermod -aG docker $USER
sudo systemctl enable docker
sudo systemctl start docker

Installing Docker Offline (Air-Gapped Environments)

For hosts with no internet access at all, Docker CE itself must be staged as offline .deb packages on a separate host that does have internet access, transferred across, and installed manually.

Docker CE is required

The cloudSwXtch installer requires Docker Engine (docker-ce). If Ubuntu's docker.io is installed and --auto_deps is not used, the installer stops without changing anything.

Do not use --auto_deps on an air-gapped host: it removes docker.io, containerd and runc first and then fails to reach Docker's repository, which leaves the host without a container runtime (GitHub issue #5949).

Build an offline Docker CE bundle (on a staging host with internet access)

Skip this step if Docker CE is already installed and running on the air-gapped target. Otherwise, on a staging host with the same Ubuntu release as the target and Docker's apt repository added, download the Docker CE packages and their dependency chain as .deb files:

mkdir -p ~/docker-offline && cd ~/docker-offline
sudo apt-get update
PKGS="docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras pigz"
apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances $PKGS | grep -E '^\w' | sort -u)
tar czf docker-offline-bundle.tar.gz *.deb

PLEASE NOTE

apt-cache depends --recurse lists the full dependency tree regardless of what's already installed on the staging host, so this works even if Docker is already present there.

When upgrading a v4.2 cloudSwXtch on Ubuntu 22.04 offline, the seven packages listed in PKGS were enough: the v4.2 installer had already installed the other dependencies.

Install Docker CE on the air-gapped host

Transfer docker-offline-bundle.tar.gz to the air-gapped host using your approved offline transfer method, then:

  1. If Ubuntu's docker.io is installed (for example, on a cloudSwXtch installed with v4.2 --auto_deps), stop the swXtch.io containers and remove docker.io. The cloudSwXtch installer prints the removal command when it finds docker.io.
  2. Install the packages with dpkg. Don't use apt-get install ./<file>.deb: apt decodes the %3a in the Docker CE file names and fails offline with "Unable to fetch some archives".

    tar xzf docker-offline-bundle.tar.gz
    sudo dpkg -i *.deb
    sudo systemctl enable --now docker
    docker ps  # confirm the daemon works before continuing
    
  3. If docker.service fails with "no sockets found via socket activation" (seen after removing docker.io), enable the socket and restart Docker:

    sudo systemctl enable --now docker.socket && sudo systemctl restart docker
    
  4. Run the swXtch.io installer without --auto_deps.