操作系统:centos7

第一步 清理

yum remove docker-*

删除 /lib 和 /run 文件夹下的docker文件夹

重启服务器

 

第二步安装启动

[root@localhost /]# uname -a
Linux localhost.localdomain 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

sudo yum install docker

启动

service docker start

或者systemctl start docker

 

第三步查看状态

[root@localhost /]# 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 Fri 2019-03-15 23:31:39 CST; 18min ago
     Docs: https://docs.docker.com
 Main PID: 6265 (dockerd)
    Tasks: 17
   Memory: 58.8M
   CGroup: /system.slice/docker.service
           ├─6265 /usr/bin/dockerd
           └─6351 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/...

Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.217997357+08:00" level=warning msg="devmapper: Usage of loopback devices is strongly discou...v section."
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.267285876+08:00" level=warning msg="devmapper: Base device already exists and has filesyste...e ignored."
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.296159659+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.297343307+08:00" level=info msg="Loading containers: start."
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.762921350+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 17...IP address"
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.859288194+08:00" level=info msg="Loading containers: done."
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.963169805+08:00" level=info msg="Daemon has completed initialization"
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.963202882+08:00" level=info msg="Docker daemon" commit=89658be graphdriver=devicemapper ver...=17.05.0-ce
Mar 15 23:31:39 localhost.localdomain dockerd[6265]: time="2019-03-15T23:31:39.993321217+08:00" level=info msg="API listen on /var/run/docker.sock"
Mar 15 23:31:39 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost /]# 

 

[root@localhost /]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.05.0-ce
Storage Driver: devicemapper
 Pool Name: docker-253:0-33588401-pool
 Pool Blocksize: 65.54kB
 Base Device Size: 10.74GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 11.73MB
 Data Space Total: 107.4GB
 Data Space Available: 17.34GB
 Metadata Space Used: 17.36MB
 Metadata Space Total: 2.147GB
 Metadata Space Available: 2.13GB
 Thin Pool Minimum Free Space: 10.74GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.149-RHEL7 (2018-07-20)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-957.5.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 982.1MiB
Name: localhost.localdomain
ID: 5N5T:DX22:Z3JB:NYOQ:OT4A:3MI7:ADIY:TUKG:OSAM:6YEZ:XKQZ:YB6D
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
         Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
[root@localhost /]#

 设置国内镜像源否则很慢:docker 设置阿里镜像源

第四步 加入开机自启动

sudo chkconfig docker on

 或者sudo service docker enable

第五步 Q&A

问题:service docker start 报Failed to start Docker Application Container Engine

解决办法:

[root@localhost ~]# mkdir -p /etc/docker
[root@localhost ~]# vi /etc/docker/daemon.json
[root@localhost ~]# cat /etc/docker/daemon.json
{ "storage-driver": "devicemapper" }
[root@localhost ~]# 

然后重新 service docker restart 就好了。

ps:

【Docker】daemon.json的作用

Docker storage driver配置

 

posted on 2019-03-15 14:12  pu20065226  阅读(441)  评论(0编辑  收藏  举报