前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >关于docker 意外停止,重新快速启动措施

关于docker 意外停止,重新快速启动措施

作者头像
Gxjun
发布2018-06-14 15:06:27
1.9K0
发布2018-06-14 15:06:27
举报
文章被收录于专栏:mlml

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

代码语言:javascript
复制
7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252

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

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

代码语言:javascript
复制
sudo docker info
代码语言:javascript
复制
➜  ~ 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

我们没有发现

<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)} span.s1 {font-variant-ligatures: no-common-ligatures} -->

Docker Root Dir: 

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

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

代码语言:javascript
复制
[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下面寻找:

<!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px 'Andale Mono'; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px 'Andale Mono'; color: #4c7aff; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)} span.s1 {font-variant-ligatures: no-common-ligatures} -->

代码语言:javascript
复制
[root@localhost ~]# ls /data1/docker/containers
7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252
[root@localhost ~]#

然后我们使用这个重启:

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

代码语言:javascript
复制
sudo docker inspect  7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252

启动你的容器

代码语言:javascript
复制
sudo docker start 7079ff99e10ac326726a364348853c0e508cad8ce00ae970f3c800f172a40252

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

代码语言:javascript
复制
[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

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

代码语言:javascript
复制
[root@localhost ~]# sudo docker exec  -it  7079ff99e10a  bash

然后就去恢复应用吧.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-05-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档