1、移除舊版本: yum remove docker \ docker-client \ docker-client-latest \ docker-common \ ... ...
1、移除舊版本:
yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine rm -rf /etc/systemd/system/docker.service.d rm -rf /var/lib/docker rm -rf /var/run/docker rm -rf /usr/local/docker rm -rf /etc/docker
2、安裝一些必要的系統工具:
yum -y install yum-utils device-mapper-persistent-data lvm2
3、添加軟體源信息:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4、更新 yum 緩存:
yum makecache fast
5、安裝 Docker-ce:
yum -y install docker-ce
6、啟動 Docker 後臺服務:
systemctl start docker
7、測試運行 hello-world:
docker run hello-world
8、安裝centos,並以後臺啟動的方式運行centos:
docker run -itd centos /bin/bash
9、進入centos鏡像:
[root@myserver ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f57d4703adc3 centos "/bin/bash" About a minute ago Up About a minute jolly_dhawan [root@myserver ~]# docker exec -it f57d4703adc3 /bin/bash [root@f57d4703adc3 /]# [root@f57d4703adc3 /]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@f57d4703adc3 /]#
至此,Docker環境搭建完成。