# vim install_centos_docker.sh
#!/bin/bash
echo "Begin to install centos docker."
echo ""
echo "begin to update yum and install yum-utils."
sudo yum update
sudo yum install -y yum-utils
echo "yum updated,yum-utils installed"echo ""
echo "begin to install docker."
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginecho "docker installed."
echo ""
sudo systemctl start docker
echo "docker started."echo "begin to install docker-compose."
sudo yum install docker-compose-plugin
echo "docker-compose installed."
echo ""
echo -e "Install centos docker \033[32mSUCCESS\033[0m"
# chmod +x install_centos_docker.sh
# sh install_centos_docker.sh
# docker version
如有报错:
Job for docker.service failed because the control process exited with error code. See “systemctl status docker.service” and “journalctl -xe” for details.
# sudu dockerd
failed to start daemon: Error initializing network controller: Error creating default "bridge" network: Failed to program NAT chain: ZONE_CONFLICT: 'docker0' already bound to a zone
解决方法1:
关闭防火墙: systemctl stop firewalld
禁止开机启动防火墙: systemctl disable firewalld
启动docker
# systemctl start docker
解决方法2:
# firewall-cmd --zone=trusted --remove-interface=docker0
# systemctl start docker