前几天分享了debian 8系统的Docker安装,本文将分享centos版本Docker安装。Docker目前仅用在64位的操作系统上。所以选择系统时需要选择x86_64后缀的版本,系统内核版本为 3.10 以上。
使用 yum 安装Docker
通过 uname -r 命令查看你当前的内核版本
![]()
安装 Docker
安装命令如下:
yum -y install docke
启动 Docker 后台服务
service docker start测试运行 hello-world
docker run hello-world如果你看到这条消息,那么它工作正常。
Hello from Docker. This message shows that your installation appears to be working correctly.

输出如图上效果。
使用脚本安装 Docker
以root 权限登录 Centos,并yum到最新。
yum update-y
执行 Docker 安装脚本,执行这个脚本会添加 docker.repo 源并安装 Docker。
curl -fsSL https://get.docker.com/ | sh
启动 Docker 进程。
docker run hello-world
测试运行 hello-world
docker run hello-world如果你看到这条消息,那么它工作正常。效果图就是上面。
Hello from Docker. This message shows that your installation appears to be working correctly
开机自启动Docker,systemctl命令
开启docker服务。
systemctl start docker
系统启动时启用docker(开机自启动)。
systemctl enable docker
关闭开机自启动
systemctl disenable docker
恭喜! 现在你已经在Centos上成功安装了Docker。