Docker CE Installation on CentOS
This guide walks you through installing and configuring Docker Community Edition (CE) on a CentOS-based system. It covers repository setup, installation, post-installation steps, and troubleshooting common permission errors.
Table of Contents
- Prerequisites
- Installation Steps
- 1. Enable EPEL Repository
- 2. Remove Older Docker Versions
- 3. Set Up Docker Repository
- 4. Install Docker CE
- 5. Start and Enable Docker Service
- Post-Installation Configuration
- Manage Docker as Non-Root User
- Uninstallation
- Troubleshooting
- References
Prerequisites
- A CentOS or RHEL-based system (CentOS 7/8, RHEL 7/8).
- sudo privileges or root access.
- Internet connectivity to download packages.
Installation Steps
1. Enable EPEL Repository
The EPEL (Extra Packages for Enterprise Linux) repository provides additional packages required by Docker CE.
2. Remove Older Docker Versions
This ensures no conflicts with previous installations.
3. Set Up Docker Repository
Install required utilities and configure the Docker CE repository:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4. Install Docker CE
5. Start and Enable Docker Service
Verify Docker is running:
Post-Installation Configuration
Manage Docker as a Non-Root User
- Create the docker group (if it doesn't exist):
- Add your user to the docker group:
-
Log out and log back in for group changes to take effect.
-
Verify you can run Docker without sudo:
Uninstallation
To remove Docker CE and related data completely:
sudo yum remove -y docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
Troubleshooting
Permission Denied on Docker Config File
If you encounter:
Fix with:
Permission Denied Connecting to Docker Daemon
Error:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: connect: permission denied
Resolve by adding your user to the docker group (see above) and restarting your session.
References
- Official Docker CE Documentation: https://docs.docker.com/engine/install/centos/