1、centOS 下载安装docker
分别执行下面命令:
#安装docker
sudo yum -y install docker
#启动docker
sudo systemctl start docker
#查看版本
docker -v
#设置开机自启
systemctl enable docker
2、可能出现问题
2.1 Failed to start docker.service: Unit docker.service not found
在安装完成之后,启动docker报此错误,则分别执行下面命令:
#卸载podman
dnf remove podman
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 docker-ce docker-ce-cli containerd.io
sudo yum install docker-ce docker-ce-cli
#启动docker
sudo systemctl start docker
参考centos8 安装docker解决:Failed to start docker.service: Unit docker.service not found
2.2 权限问题
启动docker后,不是root用户执行docker命令时,如docker -v,若报错Got permission denied while trying to connect to the Docker daemon socket at.......
则执行下面命令:
sudo chmod a+rw /var/run/docker.sock