I. Preparatory work
1. System requirements
docker requires centos to have a kernel version of no less than 3.10. centos7 meets the minimum kernel requirements.
Check the current kernel version
[root@zspc /]# uname -r
3.10.0-1160.el7.x86_64
You can see that my current kernel version is 3.10, which meets the minimum kernel requirements.
2. Uninstall the old version
You need to uninstall Docker if it was previously installed.
Just execute the following command:
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine \
docker-ce
Second, install Docker
1、Installation of dependency packages
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2 --skip-broken
2、Update the local mirror source
For domestic network reasons, we use Ali's docker source here
# set updockermirror (computing)
yum-config-manager \
--add-repo \
/docker-ce/linux/centos/
sed -i 's//\/docker-ce/g' /etc//
yum makecache fast
3. Install Docker
yum install docker-ce docker-ce-cli
Select y if prompted during installation.
4、Verify whether the installation is successful
[root@zspc /]# docker -v
Docker version 26.1.4, build 5650f9b
III. Starting Docker
Normally, all you need to do to start Docker is turn off the firewall, but this is extremely insecure behavior, so to run Docker with the firewall enabled, configure the firewall to allow Docker-related traffic.
1. Check the firewall
Execute the following command to check the firewall status and you can see that the firewall is running
[root@zspc /]# systemctl status firewalld
● - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/; enabled; vendor preset: enabled)
Active: active (running) since Tue 2024-08-13 11:28:52 CST; 24h ago
2、Configure the firewall
Docker uses a network type called bridge, which needs to be turned on in the firewall.
firewall-cmd --permanent --zone=public --add-masquerade
Docker uses the 172.17.0.0/16 network segment by default, you need to open this segment in the firewall.
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 4 -i docker0 -j ACCEPT
Reload the firewall to apply new rules
firewall-cmd --reload
4. Start Docker
systemctl start docker
Setting up boot-up
systemctl enable docker
Verify successful startup
Execute the docker ps command and the following result appears, which means that Docker has started successfully.
[root@zspc /]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES