CentOS7安装Docker
Docker 是一个开放源代码软件,是一个开放平台,用于开发应用、交付(shipping)应用、运行应用。 Docker允许用户将基础设施(Infrastructure)中的应用单独分割出来,形成更小的颗粒(容器),从而提高交付软件的速度。本篇介绍一下在CentOS7中安装Docker的步骤。
添加Docker源
对与一个全新的系统,如果我们要使用yum-config-manager
必须先安装yum-utils
1 | yum install -y yum-utils device-mapper-persistent-date lvm2 |
device-mapper-persistent-date
和lvm2
是为了支持devicemapper存储类型。
添加Docker的yum软件源
1 | yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo |
为了加速,我们这里使用阿里云的源。
重新生成yum缓存
1 | yum clean all |
安装Docker
1 | yum -y install docker-ce |
安装完成后,直接启动Docker。
1 | systemctl start docker |
配置Docker镜像源
由于GFW的存在,我们不能使用默认的Docker源,所以需要配置国内源来加速下载镜像。
1 | # 默认安装完是没有这个文件的 |
填入如下信息:
1 | { |
鉴于被二马坑了很多钱,这里就白嫖他们的了。当然,如果你们还想用其他的源,也可以在以下列表中选择:
1 | # DaoCloud |
以上都是一些公共源。
对于公司的私有源,绝大多数都没有配置证书,所以需要配置为如下方式:
1 | { |
注意,不要加http
或者https
。
配置完成后重启
1 | systemctl restart docker |
补充
由于CentOS8在今年年底要停止维护,后期运维可能会将所有系统迁移到Ubuntu上,如果是在Ubuntu下安装Docker,可参考如下
添加gpg密钥
1 | curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - |
添加软件源信息
1 | add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" |
更新
1 | apt-get -y update |
安装Docker-CE
1 | apt-get -y install docker-ce |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment