Varidata News Bulletin
Knowledge Base | Q&A | Latest Technology | IDC Industry News
Varidata Blog

How to install Docker on CentOS6?

Release Date: 2025-06-06
Step-by-step Docker installation guide on CentOS 6 server

Need to run Docker on your CentOS 6 server? While most tutorials focus on newer CentOS versions, many Hong Kong hosting providers still maintain CentOS 6 systems. This guide dives deep into the exact process of getting Docker up and running on CentOS 6, with specific optimizations for servers located in Hong Kong.

Pre-Installation System Check

Before diving into Docker installation, let’s hack our way through the preliminary requirements. Fire up your terminal and verify your system specs:

uname -r
cat /etc/redhat-release
free -m
df -h

Your system should meet these minimum requirements:

  • 64-bit architecture
  • Kernel version 2.6.32-431 or later
  • At least 2GB RAM (4GB recommended)
  • 20GB available disk space

Setting Up the EPEL Repository

First, we’ll need EPEL. Unlike CentOS 7/8, Docker installation on CentOS 6 requires some specific repository configurations. Here’s your first set of commands:

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum clean all
yum makecache

Installing Docker Dependencies

Let’s get our hands dirty with the dependency installation. CentOS 6 requires specific versions of several components to play nice with Docker:

yum install -y device-mapper-event-libs
yum install -y sqlite sqlite-devel
yum install -y lxc lxc-libs

Pro tip: If you’re running this on a Hong Kong hosting environment, consider using local mirrors to speed up the download process:

# Add to /etc/yum.repos.d/docker.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.cloud.tencent.com/docker-ce/linux/centos/6/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/docker-ce/linux/centos/gpg

Docker Installation Process

Now for the main event. We’ll install Docker using a specific version known to work well with CentOS 6:

curl -fsSL https://get.docker.com/ | sh
service docker start
chkconfig docker on

Verify your installation with:

docker --version
docker info

Post-Installation Configuration

Here’s where we optimize Docker for your Hong Kong server environment. Create or modify /etc/docker/daemon.json:

{
    "registry-mirrors": [
        "https://mirror.ccs.tencentyun.com",
        "https://registry.docker-cn.com"
    ],
    "max-concurrent-downloads": 10,
    "max-concurrent-uploads": 5,
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "10m",
        "max-file": "3"
    }
}

Network Configuration and Optimization

When running Docker on Hong Kong hosting infrastructure, network configuration becomes crucial. Let’s optimize the network stack:

# Add to /etc/sysctl.conf
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1

# Apply changes
sysctl -p

Troubleshooting Common Issues

Let’s tackle some CentOS 6-specific Docker issues you might encounter. Here’s your debugging toolkit:

IssueSolution
Device Mapper Error
rm -rf /var/lib/docker
service docker restart
Network Connectivity
iptables -I FORWARD -p all -i docker0 -j ACCEPT
service docker restart
Permission Denied
usermod -aG docker $USER
newgrp docker

Performance Optimization for Hong Kong Servers

For optimal performance in Hong Kong hosting environments, implement these tweaks:

# Add to /etc/docker/daemon.json
{
    "storage-driver": "overlay2",
    "storage-opts": [
        "overlay2.override_kernel_check=true"
    ],
    "mtu": 1450,
    "dns": [
        "8.8.8.8",
        "8.8.4.4"
    ]
}

Key points for Hong Kong server optimization:

  • Set MTU to 1450 for better compatibility with Hong Kong ISPs
  • Use overlay2 storage driver for improved performance
  • Configure DNS servers for reliable resolution
  • Implement rate limiting for container logging

Security Best Practices

Running Docker on CentOS 6 in a Hong Kong hosting environment requires additional security measures. Implement these hardening techniques:

# Configure Docker daemon security
chmod 660 /var/run/docker.sock
groupadd docker-sec
chown root:docker-sec /var/run/docker.sock

# Add security rules to Docker daemon
cat > /etc/docker/daemon.json <

Resource Management

Optimize resource allocation for your containers:

# Example container with resource limits
docker run -d \
    --name myapp \
    --memory="512m" \
    --memory-swap="1g" \
    --cpus="1.5" \
    --pids-limit=100 \
    nginx

Advanced Tips and Recommendations

For those running production workloads on Hong Kong hosting infrastructure, consider these advanced configurations:

  • Implement container health checks
  • Set up Docker metrics monitoring
  • Configure automated container updates
  • Use multi-stage builds to reduce image size
# Example health check implementation
docker run -d \
    --name webapp \
    --health-cmd="curl -f http://localhost/ || exit 1" \
    --health-interval=5m \
    --health-retries=3 \
    nginx

Conclusion

Successfully running Docker on CentOS 6 requires careful attention to system configuration and optimization, particularly in Hong Kong hosting environments. While newer versions of CentOS offer more straightforward Docker implementations, this guide demonstrates that CentOS 6 can still serve as a reliable Docker host with proper setup and maintenance.

Remember to regularly check for security updates and monitor your container performance. For optimal results in Hong Kong server environments, maintain current backups and implement the region-specific optimizations outlined in this guide. Whether you're running a development environment or production workloads, these Docker configurations will help ensure smooth operation on your CentOS 6 system.

Your FREE Trial Starts Here!
Contact our Team for Application of Dedicated Server Service!
Register as a Member to Enjoy Exclusive Benefits Now!
Your FREE Trial Starts here!
Contact our Team for Application of Dedicated Server Service!
Register as a Member to Enjoy Exclusive Benefits Now!
Telegram Skype