How to Install Docker on Rocky Linux
Step 1: Update Your System
Before installing Docker, make sure your system is up-to-date. Open a terminal and run the following commands:
sudo dnf update -y
Step 2: Install Docker Dependencies
Docker requires some dependencies to be installed. You can install them using the following command:
sudo dnf install -y dnf-plugins-core
Step 3: Add Docker Repository
Add the Docker repository to your system:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Step 4: Install Docker Engine
Install Docker Engine on Rocky Linux:
sudo dnf install -y docker-ce docker-ce-cli containerd.io
Step 5: Start and Enable Docker
Start the Docker service and enable it to start automatically on boot:
sudo systemctl start docker
sudo systemctl enable docker
Step 6: Verify Docker Installation
Verify that Docker has been successfully installed:
sudo docker --version
Step 7: Test Docker
Test Docker by running a simple "Hello World" container:
sudo docker run hello-world
Step 8: Add Your User to the Docker Group (Optional)
If you'd like to avoid using sudo
for Docker commands, add your user to the Docker group:
sudo usermod -aG docker $USER
Log out and back in for the changes to take effect.
Step 9: Test Docker as a Regular User (Optional)
As a regular user, test Docker:
docker run hello-world
This should produce the same "Hello World" output as before.
That's it! You've successfully installed Docker on Rocky Linux. You can now use Docker to run containers and manage containerized applications on your system.