centos7 下 docker-ce 安装

docker-ce 安装

一、 卸载旧版本

[ych@bogon /]$ sudo yum remove docker   docker-client     docker-client-latest   docker-common   docker-latest   docker-latest-logrotate  docker-logrotate  docker-engine

二、 安装docker依赖

在新主机上首次安装Docker CE之前,需要设置Docker存储库。之后,您可以从存储库安装和更新Docker。
设置存储库
安装所需的包。yum-utils提供了yum-config-manager 效用,并device-mapper-persistent-data和lvm2由需要devicemapper存储驱动程序。

1. 安装依赖包

[ych@bogon /]$ sudo yum update
[ych@bogon /]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

2. 设置稳定存储库

[ych@bogon /]$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

三、 安装 docker-ce

[ych@bogon /]$ sudo yum update
[ych@bogon /]$ sudo yum install docker-ce   docker-ce-cli  containerd.io  -y

docker-ce 默认安装目录为 /var/lib/docker

四、 检查是否安装成功

[ych@bogon /]$ docker -v
Docker version 19.03.8, build afacb8b

五、 设置开机启动docker

[ych@bogon /]$ sudo systemctl enable docker
[sudo] ych 的密码:
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

查看docker状态

[ych@bogon /]$ systemctl status docker

设置镜像加速器(如果没有daemon.json文件则新建)

[ych@bogon /]$ cd /etc/docker
[ych@bogon docker]$ ll
总用量 12
-rw-r--r--. 1 root root 115  5月  5 18:07 daemon.json
-rw-------. 1 root root 244  5月  3 15:26 key.json
{
 "exec-opts": ["native.cgroupdriver=systemd"], 
 "registry-mirrors": ["https://p0z5z3i2.mirror.aliyuncs.com"], // 可以到阿里云开通自己的镜像加速
 "graph":"/data/docker"
}

# 重新加载配置
[ych@bogon /]$ systemctl daemon-reload
# 重启docker
[ych@bogon /]$ systemctl restart docker
# 查看docker运行状态
[ych@bogon /]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since 四 2020-05-07 10:53:18 CST; 8s ago
     Docs: https://docs.docker.com
 Main PID: 3409 (dockerd)
    Tasks: 8
   Memory: 109.9M
   CGroup: /system.slice/docker.service
           └─3409 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

5月 07 10:53:17 bogon dockerd[3409]: time="2020-05-07T10:53:17.471862217+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
5月 07 10:53:17 bogon dockerd[3409]: time="2020-05-07T10:53:17.471935794+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 ...}" module=grpc
5月 07 10:53:17 bogon dockerd[3409]: time="2020-05-07T10:53:17.471976796+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
5月 07 10:53:17 bogon dockerd[3409]: time="2020-05-07T10:53:17.534554522+08:00" level=info msg="Loading containers: start."
5月 07 10:53:18 bogon dockerd[3409]: time="2020-05-07T10:53:18.288628498+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option ...ed IP address"
5月 07 10:53:18 bogon dockerd[3409]: time="2020-05-07T10:53:18.459453757+08:00" level=info msg="Loading containers: done."
5月 07 10:53:18 bogon dockerd[3409]: time="2020-05-07T10:53:18.767116112+08:00" level=info msg="Docker daemon" commit=afacb8b graphdriver(s)=overlay2 version=19.03.8
5月 07 10:53:18 bogon dockerd[3409]: time="2020-05-07T10:53:18.767378057+08:00" level=info msg="Daemon has completed initialization"
5月 07 10:53:18 bogon systemd[1]: Started Docker Application Container Engine.
5月 07 10:53:18 bogon dockerd[3409]: time="2020-05-07T10:53:18.801059880+08:00" level=info msg="API listen on /var/run/docker.sock"

你可能感兴趣的:(#,docker)