Docker 安装 For CentOS 7.4

安装前提条件:

CentOS 版本 7.x,本例中使用CentOS 7.4

1.安装yum-utils (yum-utils提供yum-config-manager工具包等)

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

  

2.添加docker yum源

# yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

  

3.列出历史可安装版本的docker

[root@test yum.repos.d]# yum list docker-ce --showduplicates | sort -r
 * updates: mirrors.tuna.tsinghua.edu.cn
Loaded plugins: fastestmirror
Installed Packages
 * extras: mirrors.tuna.tsinghua.edu.cn
 * epel: mirrors.tuna.tsinghua.edu.cn
docker-ce.x86_64            18.03.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.12.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.12.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.09.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.09.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.09.0.ce-1.el7.centos            @docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.06.0.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.2.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable 
docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable 
Determining fastest mirrors
 * base: mirrors.tuna.tsinghua.edu.cn
Available Packages

4.安装指定版本的docker

[root@test yum.repos.d]# yum install docker-ce-17.09.0.ce-1.el7.centos

 

5.启动docker服务

#systemctl start docker
#systemctl status docker --查看docker运行状态

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2018-04-12 14:40:25 CST; 3 weeks 0 days ago
     Docs: https://docs.docker.com
 Main PID: 879 (dockerd)
   Memory: 28.7M
   CGroup: /system.slice/docker.service
           ├─879 /usr/bin/dockerd
           └─967 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker...

Apr 12 14:40:24 test dockerd[879]: time="2018-04-12T14:40:24.772795499+08:00" level=info msg="[graphdriver] using prior storage driver: overlay"
Apr 12 14:40:24 test dockerd[879]: time="2018-04-12T14:40:24.985105572+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Apr 12 14:40:24 test dockerd[879]: time="2018-04-12T14:40:24.989165246+08:00" level=info msg="Loading containers: start."
Apr 12 14:40:25 test dockerd[879]: time="2018-04-12T14:40:25.635272236+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can ...red IP address"
Apr 12 14:40:25 test dockerd[879]: time="2018-04-12T14:40:25.688855850+08:00" level=info msg="Loading containers: done."
Apr 12 14:40:25 test dockerd[879]: time="2018-04-12T14:40:25.792474284+08:00" level=info msg="Docker daemon" commit=afdb6d4 graphdriver(s)=overlay version=17.09.0-ce
Apr 12 14:40:25 test dockerd[879]: time="2018-04-12T14:40:25.807625596+08:00" level=info msg="Daemon has completed initialization"
Apr 12 14:40:25 test dockerd[879]: time="2018-04-12T14:40:25.859396502+08:00" level=info msg="API listen on /var/run/docker.sock"
Apr 12 14:40:25 test systemd[1]: Started Docker Application Container Engine.
Apr 23 10:23:25 test dockerd[879]: time="2018-04-23T10:23:25.951186829+08:00" level=error msg="Error setting up exec command in container tomcat_01: Container b165437998d2ac8ff3c7246b10f417...is not running"
Hint: Some lines were ellipsized, use -l to show in full.

6.docker数据默认存储路径在/var/lib/docker

猜你喜欢

转载自www.cnblogs.com/dinglin1/p/8989324.html