Cloud Native 5 min read

Step-by-Step Guide to Install Docker, Docker‑Compose, and Harbor on CentOS

This tutorial walks you through removing old Docker packages, configuring yum repositories (official and Alibaba Cloud mirrors), installing a specific Docker Engine version, setting up image acceleration, verifying Docker, installing Docker‑Compose, downloading and configuring Harbor, and finally validating the Harbor registry on a CentOS system.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Step-by-Step Guide to Install Docker, Docker‑Compose, and Harbor on CentOS

1. Install Docker

Official documentation: https://docs.docker.com/engine/install/centos/

1.1 Remove old versions

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

1.2 Set up the yum repository

1.2.1 Official repository

sudo yum install yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

1.2.2 Alibaba Cloud mirror

sudo yum install yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2. Install a specific Docker Engine version

2.1 List all available versions

yum list docker-ce --showduplicates | sort -r

2.2 Install the chosen version

sudo yum install docker-ce-20.10.8-3.el7 docker-ce-cli-20.10.8-3.el7 containerd.io docker-compose-plugin

3. Configure image acceleration

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors":["https://registry.docker-cn.com","https://smym36v5.mirror.aliyuncs.com"],
  "insecure-registries":["harbor_address:harbor_port"]
}
EOF
systemctl daemon-reload
systemctl restart docker

4. Verify Docker installation

docker version

5. Install Docker‑Compose

wget https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64
chmod +x docker-compose-linux-x86_64
mv docker-compose-linux-x86_64 docker-compose
docker-compose version

6. Download and install Harbor

wget https://github.com/goharbor/harbor/releases/download/v2.9.1/harbor-offline-installer-v2.9.1.tgz

6.1 Extract and configure

tar xf harbor-offline-installer-v2.9.1.tgz
cd harbor
cp harbor.yml.tmpl harbor.yml
vim harbor.yml
Harbor configuration screenshot
Harbor configuration screenshot
Harbor configuration screenshot
Harbor configuration screenshot
Harbor configuration screenshot
Harbor configuration screenshot

6.2 Start installation

./install.sh

7. Verify Harbor

Web login default credentials: admin / Harbor12345

docker ps
Docker containers list
Docker containers list
cloud nativeDockerInstallationCentOSDocker ComposeHarborContainer Registry
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.