2.3 installing docker on CentOS

Time:2021-7-21

There are three ways to build a system development environment with docker

install

1. Manual installation

After starting the system with vagrant, install it manually
https://docs.docker.com/install/linux/docker-ce/centos/

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

#If you want to install a specific version, use 
# sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

sudo yum install -y docker-ce
sudo systemctl start docker

2. Automatic installation of vagrant

After the system is created by vagrant, the docker environment is built automatically,config.vm.provision "shell"It can be automatically executed when the virtual machine is created

 config.vm.provision "shell", inline: <<-SHELL
    sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
    sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    sudo yum install -y docker-ce
    sudo systemctl start docker
  SHELL

3. Automatic installation of docker machine

See the next section for details

4. Script automatic installation

curl -fsSL https://get.docker.com -o get-docker.sh

uninstall

sudo yum remove docker-ce
sudo rm -rf /var/lib/docker

View version

docker version
Client:
 Version: 18.03.1-ce
 API version: 1.37
 Go version: go1.9.5
 Git commit: 9ee9f40
 Built: Thu Apr 26 07:20:16 2018
 OS/Arch: linux/amd64
 Experimental: false
 Orchestrator: swarm
Server:
 Engine:
  Version: 18.03.1-ce
  API version: 1.37 (minimum version 1.12)
  Go version: go1.9.5
  Git commit: 9ee9f40
  Built: Thu Apr 26 07:23:58 2018
  OS/Arch: linux/amd64
  Experimental: false

common problem

  1. The first installation, start failure, locate the problem
#Check through systemctl
systemctl status docker
#Run execstart of systemctl directly to check
/usr/bin/dockerd