Installing Docker on CentOS 7 with Common Pitfalls and Solutions

System Requirements Verification

Verify Linux system parameters before Docker installation:

cat /etc/redhat-release
uname -r

Environment Preparation

Install essential packages if not present:

yum -y install gcc gcc-c++

Docker Removal (For Fresh Install)

Stop and remove existing Docker installations:

systemctl stop docker
yum remove docker docker-client docker-client-latest docker-common \
             docker-latest docker-latest-logrotate docker-logrotate \
             docker-engine docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
rm -rf /var/lib/containerd

Docker Enstallation Process

  1. Install prerequisite tools:
yum install -y yum-utils
  1. Configure repository (using Aliyun mirror):
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  1. Update package index:
yum makecache fast
  1. Install Docker components:
yum -y install docker-ce docker-ce-cli containerd.io
  1. Start and enable Docker service:
systemctl start docker
systemctl enable docker
  1. Verify installation:
docker version

Container Management Basics

Run test container:

docker run hello-world

Basic container operations:

docker ps
docker exec -it [container_id] /bin/bash
docker start/stop/restart [container_id]
docker rm [container_id]
docker rmi [image_id]

Common Issues and Solutinos

  1. Docker service fails to start

    • Solution: Reinstall Docker components
  2. MySQL connection issues

    • Create new user with proper privileges:
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%';
FLUSH PRIVILEGES;
  • For MySQL 8 authentication issues:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
  1. Network connectivity problems
    • Check VM resource allocation (memory, CPU)
    • Verify network configurations
    • Ensure proper firewall settings

Performance Considerations

  • Allocate sufficient resources to VM (recommended minimum 8GB RAM)
  • Use SSD storage for better performence
  • Monitor system logs during installation for potential issues

Tags: docker centos containerization devops Linux

Posted on Tue, 25 Aug 2026 16:37:42 +0000 by Stressed