1. 我们要重启这个镜像,需要知道这个镜像ID,类似这个:

7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252


那么你可以跳过下面的这个步骤:

  1. 我们先找到docker 的存放位置,默认的docker 镜像防止在/var/lib/docekr 位置,但是一般来说var的目录比较小,如果我们存的image镜像比较大的话,可能需要修改默认存储地址,这个在这里不讲.  我们采用 sudo docker info 来查询

sudo docker info
➜  ~ docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 1
Server Version: 17.09.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.49-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: moby
ID: 7BAB:WVQS:GYQ2:47HA:IWJ4:G5NR:ZEYE:GVBW:BHNJ:WQE7:SNSJ:7FMM
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 18
Goroutines: 29
System Time: 2018-05-08T01:48:46.3659886Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false


我们没有发现

Docker Root Dir: 

这个字段,所以说明目录存储在/var/lib/docker 目录下,所以我们直接在这个目录下去寻找就可以了.

我们这里是因为修改了docker的默认的存储路径:

[root@localhost ~]# sudo docker info
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 1
Server Version: 1.13.1
Storage Driver: overlay
Backing Filesystem: extfs
Supports d_type: true
Logging Driver: journald
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: docker-init
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: N/A (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.0-229.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 32
Total Memory: 31.11 GiB
Name: localhost.localdomain
ID: LONA:BCUD:HM76:FIDU:NRJZ:ZYBC:E6F2:NMEG:6KIN:KBME:7EYL:J5EZ
Docker Root Dir: /data1/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
Registries: docker.io (secure)


所以这里去/data1/docker下面寻找:


[root@localhost ~]# ls /data1/docker/containers

7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252

[root@localhost ~]# 


然后我们使用这个重启:

首先,查看我们的容器信息:

sudo docker inspect  7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252


启动你的容器

sudo docker start 7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252



然后使用sudo docker ps  查看容器状态:

[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7079ff99e10a xxxxxxx.xxx.xxx "/usr/sbin/entrypo..." 2 weeks ago Up 28 minutes elated_ramanujan




这样我们的容器就恢复了. 然后我们进入容器,去重启应用服务吧.

[root@localhost ~]# sudo docker exec  -it  7079ff99e10a  bash


然后就去恢复应用吧.



          ---- 完 ----





编程是一种快乐,享受代码带给我的乐趣!!!