SSD Nodes Learn Hosting plans →
How to do am Matt ConnorBy Matt Connor

Install Docker for Rocky Linux or AlmaLinux

Install Docker Engine with dnf on Rocky Linux or AlmaLinux, then fix Podman owning docker, SELinux bind-mount labels, and firewalld port surprises.

Rocky Linux and AlmaLinux Install Docker kora

To install Docker for Rocky Linux or AlmaLinux, add Docker own dnf repository, install engine together with compose plugin, then enable the service. Na four commands be that part, and e dey the same for both distributions because both na rebuilds of Red Hat Enterprise Linux (RHEL) and dem share the same package layout. CentOS Stream dey work the same way. Everything below apply to both, so if you still dey choose between dem, the main things to decide na the compatibility promise each project make and whether your older CPU still get support.

The installation short, so most of this guide explain wetin Enterprise Linux (EL) dey do differently from Ubuntu. Podman fit already own the docker command for your image. SELinux go confine containers only after you enable Docker SELinux support, and from that point e go block bind-mounted files until dem get the correct label. Firewalld no dey filter Docker published ports, so container port fit dey open to internet while firewall-cmd dey report say nothing dey open.

No use Docker convenience script from get.docker.com. Docker own documentation talk say dem no recommend am for production. E dey rewrite your repository configuration without asking, and you no fit safely run am again to upgrade. If you add the repository by hand, dnf upgrade go treat Docker like every other package for the system. That one also put the engine under dnf-automatic, if you get am applying security updates on a timer, so decide early whether you want Docker patches to install without manual action or you want hold dem back until maintenance window. Either way, upgrade go replace the packaged binary while the old dockerd still dey run, and needs-restarting na the command wey go tell you which services still dey run the code wey you just replace.

Podman don answer the docker command already?

Rocky Linux and AlmaLinux dey ship podman for their default repositories, and plenty VPS images install am for you. Some images go further and install podman-docker, wey put shell script for /usr/bin/docker and make am call podman. Every docker command wey you type go run podman instead, so guide wey Docker write fit start to show output wey you no expect.

The first sign na banner. The /usr/bin/docker script dey look for file wey dem name nodocker inside /etc/containers and your own ~/.config/containers directory (under $XDG_CONFIG_HOME if you set am). When neither file dey, e go print one line before e run anything:

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.

Person fit don create either file to silence the banner, so no depend on am alone. Ask the package database which package own the binary:

command -v docker
rpm -qf "$(command -v docker)"

Answer wey start with podman-docker mean say podman dey answer. Answer wey start with docker-ce-cli mean say na real Docker. If rpm -qf report say no package own the file, person install am by hand, and you suppose read the script before you trust am.

Podman dey run the same OCI images and e dey reasonable to use. If you want am, stop here. Both na Linux container engines, so if the platform decision never clear, e good make you know say FreeBSD jails dey isolate full userland instead of running layered images wey dem pull from registry. If you want Docker Engine, remove the packages wey dey conflict first. This na the list wey Docker document for RHEL:

sudo dnf remove docker docker-client docker-client-latest docker-common \
  docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc

Read wetin dnf plan to remove together with am before you confirm. For fresh VPS image, the list short. For machine wey person don use before, removing podman fit remove cockpit-podman or another tool wey depend on am.

Keeping podman alongside Docker dey possible in principle: remove only podman-docker, so the docker name go free, and runc, wey the containerd.io package replaces. Docker documentation treats podman as conflicting package, so Docker no support this arrangement. If the installation still report conflict, use the complete removal list above.

Add Docker repository with dnf config-manager

Docker dey publish RPMs for Enterprise Linux for download.docker.com. The repository file dey point to CentOS tree, and na this tree Rocky Linux and AlmaLinux dey resolve against. To point Rocky box to CentOS repository fit look like mistake until you know how both distributions come from CentOS lineage after Red Hat turn CentOS to Stream for 2020. We check am on 10 November 2026. Docker document this repository for CentOS Stream 9 and CentOS Stream 10.

sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Version 5 of dnf don remove the --add-repo argument, so that second command go fail for newer releases. Check the one wey you get, then choose the matching form:

dnf --version

If e print 5.x version, use the subcommand form instead:

sudo dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/centos/docker-ce.repo

Both commands write the same file to /etc/yum.repos.d/docker-ce.repo. Wrong form go fail with unknown-argument error instead of doing something silently wrong, so you no go miss am.

That repo file set baseurl to a path wey contain $releasever, and dnf expand that variable from your release package. Rocky Linux and AlmaLinux set am to the major version number. So e go be 9 for EL 9 and 10 for EL 10. Na why CentOS repository dey resolve correctly for Rocky box. Confirm the expansion before you install:

sudo dnf repoinfo docker-ce-stable

Read the Repo-baseurl line. E suppose end with /9/x86_64/stable or /10/x86_64/stable. If your release set $releasever to point version like 9.6, the line go show /9.6/ instead, and dnf go report Status code: 404 for that URL when e fetch metadata. Fix am by editing /etc/yum.repos.d/docker-ce.repo and replacing $releasever with the bare major number. 404 by itself no prove say na this be the problem. Red Hat list other causes for the same error, including inconsistent repository metadata and incorrect base URL. So only make the edit when Repo-baseurl actually show point release. If e already end with the major number, replacing the variable no go change anything.

Install the engine and the compose plugin

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

Package five dey, and each get one work. docker-ce na the daemon, dockerd. docker-ce-cli na the docker command wey you dey type. containerd.io na the container runtime wey daemon dey control. docker-buildx-plugin dey build images. docker-compose-plugin dey provide docker compose as subcommand.

These packages no install hyphenated docker-compose binary. Na Compose v1 be that, and Docker declare am end of life after Compose v2 become generally available. Anything wey dey call docker-compose with hyphen need update to docker compose with space.

The first install go stop to import Docker signing key and show you the fingerprint. The key come from gpgkey=https://download.docker.com/linux/centos/gpg for the repo file wey you just add, so compare the fingerprint wey dnf print with that URL before you accept am.

One failure dey happen often enough make we name am. If dnf report say containerd.io require container-selinux and nothing provide am, your AppStream repository no dey enabled. Run dnf repolist and confirm say appstream dey listed, because na there container-selinux dey ship for EL 9 and EL 10.

Start Docker and confirm say e dey run

sudo systemctl enable --now docker
sudo systemctl status docker --no-pager
sudo docker run --rm hello-world

Docker RPM packages dey leave daemon stopped and disabled after installation. Na why this step dey appear for Docker CentOS page but e no dey for Ubuntu page, where deb package start the service for you. If you skip enable, Docker go run until the next reboot. After that, e go stay down and carry every container go down with am.

systemctl status suppose show Active: active (running). hello-world container suppose print This message shows that your installation appears to be working correctly. and exit. If e print permission error for /var/run/docker.sock instead, you no add sudo. The docker group section below go fix am.

Check the compose plugin separately, because na different package and e fit no dey even when engine dey work:

docker compose version

For fresh installation, healthy answer suppose look like Docker Compose version v5.7.0. Na the version wey Docker EL 9 repository dey ship as of 10 November 2026. No let the jump from v2 to v5 confuse you. Docker release Compose v5 for 2025 as functionally identical to v2, and e skip the numbers wey dey between dem to avoid confusion with old Compose file formats wey dem label v2 and v3. Docker support both Compose v2 and Compose v5. So older box wey answer v2.x.x still dey work, and dnf upgrade go move am to v5. Getting your services back after reboot na separate matter from enabling the daemon, and restart policies decide whether Compose services go come back when system boot.

Why bind mount dey give permission denied?

Rocky Linux and AlmaLinux dey run SELinux (Security-Enhanced Linux) for enforcing mode by default. Confirm am with getenforce, wey go print Enforcing.

Host enforcement no dey confine Docker containers by itself. Docker SELinux support na daemon setting, selinux-enabled, wey dey off by default, and docker-ce package no turn am on. When e dey off, containers dey start as spc_t, wey be unconfined type. So bind mount fit work without any label, and SELinux no give the container any separation from the host. To make SELinux confine your containers, enable the setting for /etc/docker/daemon.json and restart the daemon. If that file already get settings, add the key to the existing object instead of overwriting the file:

echo '{ "selinux-enabled": true }' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker

When labelling dey on, Docker containers dey run under SELinux type container_t. The policy give that type full access to files wey get container_file_t label and some filesystem types like nfs_t, plus read access to some others like container_ro_file_t. E no give access to the generic labels wey ordinary host directories get. Directory wey you create for the host get the label wey e inherit from the parent path. So the container go receive denial even when owner, group and mode look correct from the host side. Reproduce am with three commands:

sudo mkdir -p /srv/site
echo hello | sudo tee /srv/site/index.html
sudo docker run --rm -v /srv/site:/usr/share/nginx/html:ro nginx:alpine cat /usr/share/nginx/html/index.html

The container go print:

cat: can't open '/usr/share/nginx/html/index.html': Permission denied

Two commands go show you the cause. ls -ldZ /srv/site go print the label. For path under /srv, the label na system_u:object_r:var_t:s0, no be container_file_t. Then sudo ausearch -m avc -ts recent go print the kernel audit record. The record contain avc: denied { read }, an scontext= field wey name container_t, and an tcontext= field wey name the label wey you just see for the directory. The mismatch between those two fields na the whole problem.

The fix na suffix for the volume argument. Docker go relabel the path for you:

sudo docker run --rm -v /srv/site:/usr/share/nginx/html:ro,z nginx:alpine cat /usr/share/nginx/html/index.html

:z for lower case relabels the content as shared, so many containers fit use the same directory. :Z for upper case relabels am as private and unshared, tied to one container. Another container wey read the same path go then receive denial. Use :z for anything wey sidecar or backup container also dey touch. Use :Z for database directory wey one container own.

Docker documentation get warning wey worth repeating, because the relabel dey recursive. Bind-mounting system directory like /home or /usr with :Z "renders your host machine inoperable and you may need to relabel the host machine files by hand". Point these suffixes to directories wey you create for the container. Never point dem to system path.

For Compose, put the suffix for the same string:

services:
  web:
    image: nginx:alpine
    volumes:
      - /srv/site:/usr/share/nginx/html:ro,z

Two limits easy to miss. --mount flag no fit set SELinux label at all, so use -v when you need one. Named volumes no need suffix, because Docker dey label the directories wey e create under /var/lib/docker/volumes by itself.

No turn SELinux off. Use sudo setenforce 0 only as one-minute test: if the container work after that, SELinux na wetin dey block am, though e no mean say na bind-mount label cause am. Read tcontext= field inside the denial. If na the directory label, :z na the answer. If e name device, the fix usually na policy boolean instead, like sudo setsebool -P container_use_xserver_devices 1 for X server device wey you mount inside the container. Put enforcing back with sudo setenforce 1 immediately. For Enterprise Linux, permission denied for bind mount get two separate causes wey look the same from inside the container. One na SELinux label. The other na ordinary numeric user and group ownership. Na this one PUID and PGID variables dey solve. ls -lnZ go show mode, numeric owner and label for one line, so you fit know which one you dey fight.

Why published port dey reachable when firewalld look closed?

Firewalld na the default firewall for Rocky Linux and AlmaLinux. Check say e dey run with sudo systemctl is-active firewalld. If you never configure am for this box, open SSH and web port with firewalld first, because the surprise below only make sense after you get working zone ruleset to compare with. Now publish one port and check wetin firewalld think say dey open:

sudo docker run -d --name web -p 8080:80 nginx:alpine
sudo firewall-cmd --list-ports

firewall-cmd dey print empty line. From another machine, curl -I http://YOUR_SERVER_IP:8080/ dey return HTTP/1.1 200 OK. The port dey open to internet, but your firewall report nothing.

The cause na the path wey packet dey follow. Firewalld zone rules dey filter traffic wey address the host itself. Published port no address the host directly: Docker install destination NAT (network address translation) rule wey rewrite the destination to the container address before packet reach the host input path. So kernel forward the packet instead of delivering am locally. Docker then put im bridge interfaces for firewalld zone called docker wey target na ACCEPT, and e add forwarding policy called docker-forwarding wey allow forwarding from any zone enter docker zone. Your zone rules no ever see the packet.

The cleanest fix no need firewall rule. Bind the host side of the publish to loopback and put reverse proxy in front of am:

sudo docker rm -f web
sudo docker run -d --name web -p 127.0.0.1:8080:80 nginx:alpine
curl -I http://127.0.0.1:8080/

The local curl dey return HTTP/1.1 200 OK, and the same request from another machine no connect again. With Docker default settings, -p argument wey no get host address dey publish for every interface. The exception na daemon wey person change the default binding address, for example with "ip": "127.0.0.1" inside /etc/docker/daemon.json. Unless you know say dem do that for this box, treat bare -p 8080:80 as decision to expose the service publicly.

When you need service wey some addresses fit reach but others no fit, Docker reserve chain for you. DOCKER-USER dey process before Docker own accept rules, so rule wey you put there go survive Docker restart and rewrite of im chains:

sudo iptables -I DOCKER-USER -i enp1s0 ! -s 203.0.113.10 -j DROP
sudo iptables -S DOCKER-USER

Take interface name from ip route show default instead make you assume say na eth0, because current EL images dey use names like enp1s0 or ens3. For Rocky and AlmaLinux, iptables command na compatibility layer on top of nftables, and you fit see Docker chains through am. Rules wey you add this way go disappear after reboot unless you save dem, so write dem inside systemd unit once you confirm say dem dey work.

Docker Engine 28.0, released in 2025, close one nearby security hole: direct routed access to container ports wey you never publish now dey blocked inside DOCKER chain. That change no affect published ports, so everything above still apply for current versions. One operational habit worth forming be this: after any sudo firewall-cmd --reload, test published port again. If e stop answering, sudo systemctl restart docker reinstall Docker rules.

Ubuntu administrators dey meet the same problem through different tool, wey be why published Docker ports dey ignore ufw rules. NAT path na the cause for both cases. Na only the firewall in front of am dey change.

Add non-root user join docker group

If you dey type sudo before every docker command, e go soon tire you. docker group fit remove that need:

sudo usermod -aG docker $USER
newgrp docker
docker run --rm hello-world

usermod -aG dey edit /etc/group, but your current shell already get its old group list. So the change no go apply until you open new shell. newgrp docker dey start shell with the new group attached, so you fit test am immediately. New SSH sessions go pick am up by themselves.

Make you understand wetin that group dey grant. Membership gives write access to /var/run/docker.sock. Anything wey fit talk to that socket fit ask the daemon to start container wey mounts the host filesystem. One command fit show wetin this mean:

docker run --rm -v /:/host alpine wc -l /host/etc/shadow

This command dey read file wey only root fit read, from account wey no get sudo rights. Docker own post-install documentation talk the same thing: docker group grants privileges wey equivalent to root. Add account to am only if you for also give that account sudo. If you dey set up accounts for new server, decide this together with the rest of your least-privilege user setup on a VPS, instead of deciding am later.

Docker also releases rootless mode wey runs daemon as unprivileged user. Na separate install path, and e changes how storage drivers and ports below 1024 dey behave. So plan am as separate project, instead of flag wey you go add later.

Wey to go next

Now you get the engine, the compose plugin, one service wey fit survive reboot, and the three EL-specific behaviours wey we document above. The next step na one compose.yaml for each service, and the anatomy of a Compose file explain the file format and the commands wey drive am. If na your first container host, running Docker on a VPS explain the sizing, storage, and image-hygiene questions wey this guide no cover.

FAQ

Docker's CentOS repository dey work for Rocky Linux and AlmaLinux?

Yes. Add https://download.docker.com/linux/centos/docker-ce.repo with dnf config-manager. The baseurl for that file get $releasever, and Rocky Linux plus AlmaLinux go expand am to the major version number. So, an EL 9 box go resolve to the CentOS 9 tree, while an EL 10 box go resolve to the CentOS 10 tree. Confirm the expansion with sudo dnf repoinfo docker-ce-stable and read the Repo-baseurl line. If that line show a point release like 9.6 and dnf report Status code: 404 when e dey fetch metadata, edit /etc/yum.repos.d/docker-ce.repo to use the bare major number. If the line already show the major number, the 404 get another cause, like inconsistent repository metadata or wrong base URL. Editing the variable no go help.

Docker and podman fit dey installed for the same server?

Docker documentation list podman and runc as conflicting packages and tell you to remove both before you install Docker Engine. The direct clash na the podman-docker package. E own /usr/bin/docker and turn every docker command to a podman command. Run rpm -qf "$(command -v docker)" to see which package own that path. If the output start with podman-docker, na podman dey answer. Docker no support keeping both engines for the same layout, so for server wey matter, choose one.

Why my container dey get permission denied for a bind mount?

SELinux dey enforce by default for Rocky Linux and AlmaLinux. Once Docker's selinux-enabled setting dey enabled (e dey off by default), containers dey run as type container_t. That type no get access to the generic labels wey ordinary host directories carry. So, directory wey you create go still deny access, no matter the owner and mode. Confirm am with ls -ldZ on the host path and sudo ausearch -m avc -ts recent, wey print avc: denied with the two contexts wey no match. Add :z to the volume argument for content wey containers share, or :Z for content wey one container alone dey use. Never point :Z to /home or /usr, because the relabel dey recursive and go break the host.

I need open port for firewalld before I publish container port?

No, and na that be the problem. Docker's NAT rule rewrite the destination address before the packet reach the host's input path, so firewalld zone rules never inspect am. Docker also put its bridges inside firewalld zone wey dem call docker, with target ACCEPT. Container wey start with -p 8080:80 fit receive traffic from internet while sudo firewall-cmd --list-ports print nothing. Publish to specific address with -p 127.0.0.1:8080:80 when na only the host suppose reach the service, or put filtering rules inside DOCKER-USER chain. Docker dey process that chain before e process its own accept rules.

Adding my user to docker group safe?

E grant root access. Member of docker group fit write to /var/run/docker.sock, and docker run --rm -v /:/host alpine wc -l /host/etc/shadow fit then read root-only file from account wey no get sudo rights. Docker post-install documentation talk the same equivalence. Add only accounts wey you go already trust with sudo, and continue to use sudo docker for shared or service accounts. Rootless mode na the alternative when you need containers under unprivileged user. E get separate install path, no be setting.

Dis article help you?