How to Install Docker on Rocky Linux 9
Installing Docker on Rocky Linux 9 is a straightforward process. Docker allows you to run applications in containers, which are isolated environments separate from the host system. This guide will walk you through the steps to get Docker up and running on your Rocky Linux 9 machine.
Step 1: Update Your System
Before installing any new software, it's always a good idea to update your system packages to the latest versions. Open a terminal and run the following command:
sudo dnf update -y
Step 2: Install Required Packages
Docker requires certain packages to be installed on your system. Install these prerequisites by running:
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2
Step 3: Add the Docker Repository
Next, you need to add the Docker CE (Community Edition) repository to your system. Run the following command:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Step 4: Install Docker
With the Docker repository added, you can now install Docker by running:
sudo dnf install -y docker-ce docker-ce-cli containerd.io
Step 5: Start and Enable Docker
After installing Docker, you need to start the Docker service and enable it to start on boot. Use the following commands:
sudo systemctl start docker
sudo systemctl enable docker
Step 6: Verify Docker Installation
To verify that Docker has been installed successfully, you can run the following command to check the Docker version:
docker --version
You should see the installed Docker version as the output.
Step 7: Add Your User to the Docker Group
By default, you need root privileges to run Docker commands. To avoid using sudo
with every Docker command, add your user to the Docker group:
sudo usermod -aG docker $(whoami)
Log out and log back in for the changes to take effect. This will grant your user access to run Docker commands without sudo
.
Conclusion
Congratulations! You have successfully installed Docker on Rocky Linux 9. You are now ready to start deploying applications using Docker containers. If you have any questions or run into any issues, feel free to consult the official Docker documentation.