]$ sudo rpm -qa docker* #先查看是否安装,然后再卸载
]$ sudo yum remove docker #也可以直接运行此命令卸载
docker-client docker-client-latest docker-common docker-latest docker-latest-logrotatte docker-logrotate docker-selinux docker-engine-selinu dokcer-engine
]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
]$ sudo yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
]$ sudo sed -i ‘s/download.docker.com/mirrors.ustc.edu.cn\/docker-ce/g‘ /etc/yum.repos.d/docker-ce.repo #使用国内源
]$ sudo yum makecache fast
]$ sudo yum install docker-ce -y
]$ sudo systemctl enable docker
]$ sudo systemctl start docker
在测试或开发环境中Docker官方为了简化安装流程,提供了一套便捷的安装脚本,CentOS系统上可以使用这套脚本安装,另外可以通过--mirror选项使用国内源进行安装
]$ curl -fsSL get.docker.com -o get-docker.sh
]$ sudo sh get-docker.sh --mirror Aliyun
]$ sudo systemctl enable docker
]$ sudo systemctl start docker
]$ docker run hello-world
Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/hello-world
...省略
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
输出以上信息说明安装成功
echo -e "{\n \"registry-mirrors\": [ \"https://hub-mirror.c.163.com\",\"https://mirror.baidubce.com\"] \n}" > /etc/docker/daemon.json
]$ docker info
...省略
Registry Mirrors:
https://hub-mirror.c.163.com/
https://mirror.baidubce.com/
...省略
有上面信息即配置成功
原文:https://www.cnblogs.com/wanwz/p/12785072.html