Installing Docker CE on Rocky Linux 9.6
This guide walks you through installing Docker Community Edition on a Rocky Linux 9.6 VM. If you're using GitHub Codespaces, skip this—Docker is already installed.
Prerequisites
- Rocky Linux 9.6 VM with sudo access
- Internet connectivity
- At least 2GB RAM, 10GB disk space
Step 1: Remove Old Docker Versions (if any)
If you have older Docker packages installed, remove them first:
sudo dnf remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine \
podman \
runcNote: Rocky Linux 9.6 comes with Podman by default. We're removing it to avoid confusion, though Docker and Podman can coexist.
Step 2: Install Required Packages
Install dnf-plugins-core to manage repositories:
sudo dnf install -y dnf-plugins-coreStep 3: Add the Docker Repository
Add the official Docker CE repository:
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repoWhy RHEL repo? Rocky Linux 9 is binary-compatible with RHEL 9, so the RHEL Docker packages work perfectly. For Rocky 9.x, we use the RHEL repository instead of CentOS.
Step 4: Install Docker CE
Install Docker Engine, CLI, containerd, and Compose plugin:
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginWhen prompted about GPG keys, verify the fingerprint matches:
060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
Type y to accept.
Step 5: Start and Enable Docker
Start the Docker service and enable it to start on boot:
sudo systemctl start docker
sudo systemctl enable dockerVerify it's running:
sudo systemctl status dockerYou should see active (running) in green.
Step 6: Add Your User to the Docker Group
By default, Docker requires root. Add your user to the docker group to run without sudo:
sudo usermod -aG docker $USERImportant: Log out and log back in for this to take effect, or run:
newgrp dockerStep 7: Verify Installation
Test that Docker works without sudo:
docker --version
docker run hello-worldExpected output:
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
Also verify Docker Compose:
docker compose versionTroubleshooting
"Permission denied" when running docker
You either:
- Didn't add your user to the docker group
- Didn't log out and back in after adding
Fix:
sudo usermod -aG docker $USER
# Then log out and log back inDocker service won't start
Check the logs:
sudo journalctl -u docker.service -n 50Common causes:
- Conflicting container runtime (podman)
- Disk space issues
- SELinux blocking (check with
sudo ausearch -m avc -ts recent)
"No space left on device"
Docker stores images and containers in /var/lib/docker. Check disk space:
df -h /var/lib/dockerClean up unused resources:
docker system prune -aSELinux Issues
If you see SELinux denials, you have options:
Option 1: Set SELinux to permissive (not recommended for production):
sudo setenforce 0Option 2: Install Docker SELinux policy (usually pre-installed on Rocky 9.6):
sudo dnf install -y container-selinuxNote: Rocky Linux 9.6 typically has better SELinux integration with containers out of the box.
Optional: Configure Docker
Change Docker's Storage Location
If you want Docker to store data on a different disk:
-
Stop Docker:
sudo systemctl stop docker
-
Create/edit
/etc/docker/daemon.json:{ "data-root": "/path/to/new/location" } -
Move existing data (if any):
sudo mv /var/lib/docker /path/to/new/location
-
Start Docker:
sudo systemctl start docker
Enable Live Restore
Keep containers running when Docker daemon restarts:
Edit /etc/docker/daemon.json:
{
"live-restore": true
}Restart Docker:
sudo systemctl restart dockerVerification Checklist
Before proceeding to the labs, verify:
-
docker --versionshows Docker version 24.x or newer (25.x recommended for Rocky 9.6) -
docker compose versionshows Compose v2.x -
docker run hello-worldworks without sudo -
docker psreturns an empty list (no errors)
Next Steps
Return to the Week 1 README and proceed to Lab 1.