How to Install Docker on CentOS 7 & RHEL 7
1. Update Your System
Before installing Docker, it's essential to update your system to ensure all existing packages are up to date:
2. Uninstall Old Versions of Docker
If you have any older versions of Docker installed, remove them to avoid conflicts:
3. Install Required Dependencies
Ensure that the yum-utils
package is installed, which provides the yum-config-manager
utility:
4. Set Up the Docker Repository
Add the official Docker repository to your system:phoenixNAP | Global IT Services+1DigitalOcean+1
5. Install Docker Engine
Install the Docker Engine package:
6. Start and Enable Docker
Start the Docker service and enable it to start on boot:Docker Documentation
7. Verify Docker Installation
To verify that Docker is installed correctly, run the following command:
This command downloads a test image and runs it in a container. If Docker is installed correctly, it will print a confirmation message.Docker Documentation
8. (Optional) Run Docker Commands Without sudo
By default, Docker commands require root privileges. To run Docker commands as a non-root user:
-
Create the
docker
group if it doesn't exist:Docker Documentation+1DigitalOcean+1
-
Add your user to the
docker
group:DigitalOcean
-
Log out and log back in to apply the group membership.
Note: These instructions are based on the official Docker documentation for CentOS 7.