Docker CentOS 安装

Docker支持以下的CentOS版本:

  • CentOS 7 (64-bit)
  • CentOS 6.5 (64-bit) 或更高的版本

前提条件

目前,CentOS 仅发行版本中的内核支持 Docker。

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。

Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本

使用 yum 安装(CentOS 7下)

Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。

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

[root@localhost /]# uname -r

安装 Docker

从 2017 年 3 月开始 docker 在原来的基础上分为两个分支版本: Docker CE 和 Docker EE。

Docker CE 即社区免费版,Docker EE 即企业版,强调安全,但需付费使用。

本文介绍 Docker CE 的安装使用。

移除旧的版本:

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

安装一些必要的系统工具:

 yum install -y yum-utils device-mapper-persistent-data lvm2

添加软件源信息:

 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新 yum 缓存:

 yum makecache fast

安装 Docker-ce:

 yum -y install docker-ce

启动 Docker 后台服务

 systemctl start docker

测试运行 hello-world

[root@localhost /]# docker run hello-world

 

 

彩蛋:

使用 [root@localhost /]# docker run hello-world  命令报错

[root@localhost /]# docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest:

可以试下关闭防火墙

检查防火墙的状态:

[root@localhost ~]# systemctl list-unit-files|grep firewalld.service

关闭防火墙:

 

 #停止firewall

[root@localhost ~]# systemctl stop firewalld.service       

#禁止firewall开机启动

[root@localhost ~]# systemctl disable firewalld.service     

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值