Installation and uninstallation of docker under CentOS7

1. Environment

  • Linux version: CentOS Linux release 7.3.1611 (Core)
  • The network is unblocked (you can access Baidu)

2. Uninstall the old version of docker

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

3. Install gcc

# 查看gcc版本
gcc -v

# 安装gcc
yum -y install gcc
yum -y install gcc-c++

4. Install the yum-utils package

yum install -y yum-utils

5. Set up a stable repository

  • It is recommended to use Alibaba Cloud's mirror library
yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

6. Update yum package index

yum makecache fast

7. Install the latest version of Docker Engine and container

yum -y install docker-ce docker-ce-cli containerd.io

8. Start Docker

#启动Docker
systemctl start docker

#查看docker版本信息
docker version

#测试helloworld
docker run hello-world

#查看镜像
docker images

Insert picture description here

9. Configure Mirror Acceleration

mkdir -p /etc/docker
vim /etc/docker/daemon.json

#添加自己的镜像加速器地址(json),注册一个阿里云账号即可拥有
{
    
    
  "registry-mirrors": ["https://自己的编码.mirror.aliyuncs.com"]
}

systemctl daemon-reload
systemctl restart docker

ps -ef | grep docker

10. Uninstall docker

systemctl stop docker
yum -y docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
  • Docker official documentation: https://docs.docker.com/engine/install/centos/
  • Aliyun official website: https://cn.aliyun.com/

Guess you like

Origin blog.csdn.net/houwanle/article/details/111462117