Centos 7 安装Docker

导读:本篇文章讲解 Centos 7 安装Docker,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

介绍:

Docker目前分为两个版本:社区版本(CE)和企业版本(EE)。通常情况下,用户使用社区版本可以满足大部分需求;社区版本每个月会发布一次尝鲜(Edge)版本,每个季度(3、6、9、12月)会发行一次稳定(Stable)版本。版本号命名格式为“年份.月份”,如2018年6月发布的版本号为v18.06

一、Centos环境安装Docker

Docker目前支持Centos7及以后的版本,64位操作系统,内核版本至少为3.10

1、首先,为了方便添加软件源,以及支持devicemapper存储类型,安装如下软件包

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

2、添加Docker稳定版本的yum软件源

[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/Linux/centos/docker-ce.repo 

3、更新yum软件源缓存,并安装docker

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

4、启动的时候如果报错(可选)

Centos 7 安装Docker

查看错误信息:此linux的内核中的selinux不支持overlay2 graph driver

Centos 7 安装Docker

5、解决方法:在docker里禁用selinux,设置–selinux-enabled更改为–selinux=enabled=false

[root@localhost ~]# vim /etc/sysconfig/docker

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

6、重启docker

[root@localhost ~]# systemctl restart docker

7、docker启动状态

[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 四 2018-06-21 15:02:15 CST; 30s ago
     Docs: http://docs.docker.com
 Main PID: 49048 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─49048 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=...
           └─49054 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /v...

6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.305056047+08:00" level=warning msg="Your kernel does not support pids lim...scarded."
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.305323128+08:00" level=info msg="Loading containers: start."
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.563230572+08:00" level=info msg="Firewalld running: false"
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.861178100+08:00" level=info msg="Default bridge (docker0) is assigned wit... address"
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.929666166+08:00" level=info msg="Loading containers: done."
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.935373703+08:00" level=warning msg="Not using native diff for overlay2, t...r to fix"
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.945844337+08:00" level=info msg="Daemon has completed initialization"
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.945866083+08:00" level=info msg="Docker daemon" commit="b2f74b2/1.13.1" g...on=1.13.1
6月 21 15:02:15 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
6月 21 15:02:15 localhost.localdomain dockerd-current[49048]: time="2018-06-21T15:02:15.956347424+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.

二、Ubuntu环境下安装Docker

Ubuntu操作系统对Docker的支持十分成熟,可以支持包括x86_64、armhf、s390x(IBMZ)、ppc641e等系统架构,是要是64位即可。

Docker目前支持的最低Ubuntu版本为14.04LTS,但实际上从稳定性上考虑,推荐使用16.04LTS或18。0.4LTS版本,并且系统内核越新越好,以支持Docker最新的特性。

1、安装必要的一些系统工具

apt-get update

2、添加源的gpg密钥

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

3、写入软件源信息

add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

4、更新并安装Docker-CE

apt-get -y update
apt-get -y install docker-ce

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/95297.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!