Linux CentOS使用yum安装Docker

Docker支持以下的CentOS版本:
目前,CentOS仅发行版本中的内核支持Docker.
Docker运行在CentOS7上,要求系统为64位、系统内核版本为3.10以上.
Docker运行在CentOS-6.5或更高的版本的CentOS上,要求系统为64位、系统内核版本为2.6.32-431或者更高版本.
Docker要求CentOS系统的内核版本高于3.10,查看本页面的前提条件来验证你的CentOS版本是否支持Docker.

通过uname -r命令查看你当前的内核版本

[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64

1.移除旧的版本

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

2.安装一些必要的系统工具

[root@localhost ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2

3.添加软件源信息

[root@localhost ~]# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

4.更新 yum 缓存

[root@localhost ~]# sudo yum makecache fast

5.安装 Docker-ce

[root@localhost ~]# sudo yum -y install docker-ce

6.启动 Docker 后台服务

[root@localhost ~]# sudo systemctl start docker

7.测试运行 hello-world

[root@localhost ~]# docker run hello-world
# 由于本地没有hello-world这个镜像,所以会下载一个hello-world的镜像,并在容器内运行.

猜你喜欢

转载自www.cnblogs.com/apollo1616/p/10320128.html