当前位置: 首页 > news >正文

测试 Docker 的实时恢复功能

1.编辑 Docker 守护进程配置文件/etc/docker/daemon. json,启用实时恢复功能。在该文件中添加以下内容

[root@host1 ~]# vi /etc/docker/daemon.json
[root@host1 ~]# cat /etc/docker/daemon.json
{"registry-mirrors": ["https://9fbd5949cbc94e4a9581e33b9077c811.mirror.swr.myhuaweicloud.com","https://jnh8ca4k.mirror.aliyuncs.com"],"insecure-registries": ["192.168.197.9:5000"]"live-restore": true
}

2.重启 Docker 守护进程

[root@host1 ~]# vi /etc/docker/daemon.json
[root@host1 ~]# cat /etc/docker/daemon.json
{"registry-mirrors": ["https://9fbd5949cbc94e4a9581e33b9077c811.mirror.swr.myhuaweicloud.com","https://jnh8ca4k.mirror.aliyuncs.com"],"insecure-registries": ["192.168.197.9:5000"]"live-restore": true
}
[root@host1 ~]# systemctl restart docker
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
[root@host1 ~]# vi /etc/docker/daemon.json
[root@host1 ~]# cat /etc/docker/daemon.json
{"registry-mirrors": ["https://9fbd5949cbc94e4a9581e33b9077c811.mirror.swr.myhuaweicloud.com","https://jnh8ca4k.mirror.aliyuncs.com"],"insecure-registries": ["192.168.197.9:5000"],"live-restore": true
}
[root@host1 ~]# systemctl restart docker
[root@host1 ~]# docker info
Client: Docker Engine - CommunityVersion:    28.4.0Context:    defaultDebug Mode: falsePlugins:buildx: Docker Buildx (Docker Inc.)Version:  v0.27.0Path:     /usr/libexec/docker/cli-plugins/docker-buildxcompose: Docker Compose (Docker Inc.)Version:  v2.39.2Path:     /usr/libexec/docker/cli-plugins/docker-composeServer:Containers: 13Running: 1Paused: 0Stopped: 12Images: 20Server Version: 28.4.0Storage Driver: overlay2Backing Filesystem: xfsSupports d_type: trueUsing metacopy: falseNative Overlay Diff: trueuserxattr: falseLogging Driver: json-fileCgroup Driver: systemdCgroup Version: 2Plugins:Volume: localNetwork: bridge host ipvlan macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file local splunk syslogCDI spec directories:/etc/cdi/var/run/cdiSwarm: inactiveRuntimes: io.containerd.runc.v2 runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 05044ec0a9a75232cad458027ca83437aae3f4darunc version: v1.2.5-0-g59923efinit version: de40ad0Security Options:seccompProfile: builtincgroupnsKernel Version: 5.14.0-611.el9.x86_64Operating System: CentOS Stream 9OSType: linuxArchitecture: x86_64CPUs: 8Total Memory: 7.47GiBName: host1ID: af1a50fb-c1e8-4693-96ea-aea71e06623bDocker Root Dir: /var/lib/dockerDebug Mode: falseExperimental: falseInsecure Registries:192.168.197.9:5000::1/128127.0.0.0/8Registry Mirrors:https://9fbd5949cbc94e4a9581e33b9077c811.mirror.swr.myhuaweicloud.com/https://jnh8ca4k.mirror.aliyuncs.com/Live Restore Enabled: true

        注意:第一次错误的原因是 json 格式的问题“少个英文逗号”,修改后成功运行!!!

3.基于 httpd 镜像创建一个运行 Apache 服务容器,然后查看正在运行的容器

[root@host1 ~]# docker run --rm -d --name web1 -p 8080:80 httpd
63625b693a81c137db99ab83ca90ef7ebf48bbf5b30a5923e7df99d9fd0d367b
[root@host1 ~]# docker ps
CONTAINER ID   IMAGE      COMMAND                   CREATED          STATUS          PORTS                                         NAMES
63625b693a81   httpd      "httpd-foreground"        14 seconds ago   Up 13 seconds   0.0.0.0:8080->80/tcp, [::]:8080->80/tcp       web1
0dbf7ea2178e   registry   "/entrypoint.sh /etc…"   6 days ago       Up 3 minutes    0.0.0.0:5000->5000/tcp, [::]:5000->5000/tcp   myregistry

4.重新加载 Docker守护进程,然后查看正在运行的容器

[root@host1 ~]# systemctl reload docker
[root@host1 ~]# docker ps
CONTAINER ID   IMAGE      COMMAND                   CREATED          STATUS          PORTS                                         NAMES
63625b693a81   httpd      "httpd-foreground"        50 seconds ago   Up 49 seconds   0.0.0.0:8080->80/tcp, [::]:8080->80/tcp       web1
0dbf7ea2178e   registry   "/entrypoint.sh /etc…"   6 days ago       Up 4 minutes    0.0.0.0:5000->5000/tcp, [::]:5000->5000/tcp   myregistry

5.使用 kill 命令结束 dockerd 守护进程,然后查看正在运行的容器

[root@host1 ~]# kill -SIGHUP $(pidof dockerd)
[root@host1 ~]# docker ps
CONTAINER ID   IMAGE      COMMAND                   CREATED         STATUS         PORTS                                         NAMES
63625b693a81   httpd      "httpd-foreground"        2 minutes ago   Up 2 minutes   0.0.0.0:8080->80/tcp, [::]:8080->80/tcp       web1
0dbf7ea2178e   registry   "/entrypoint.sh /etc…"   6 days ago      Up 5 minutes   0.0.0.0:5000->5000/tcp, [::]:5000->5000/tcp   myregistry

        可以发现该容器还在运行

6.访问该容器提供的 Apache 服务,结果表示该服务正常

[root@host1 ~]# curl http://127.0.0.1:8080
<html><body><h1>It works!</h1></body></html>

7.实验完毕,停止该容器后其自动被删除,恢复实验环境

[root@host1 ~]# docker stop logspout
Error response from daemon: No such container: logspout
[root@host1 ~]# docker ps -a
CONTAINER ID   IMAGE                          COMMAND                   CREATED          STATUS                        PORTS                                         NAMES
63625b693a81   httpd                          "httpd-foreground"        6 minutes ago    Up 6 minutes                  0.0.0.0:8080->80/tcp, [::]:8080->80/tcp       web1
6a4be1b13463   alpine:latest                  "top"                     30 minutes ago   Exited (143) 30 minutes ago                                                 test
e9786682c0ba   redis                          "docker-entrypoint.s…"   49 minutes ago   Exited (0) 47 minutes ago                                                   redis
96632885a463   lagoudocker/cadvisor:v0.37.0   "/usr/bin/cadvisor -…"   24 hours ago     Exited (0) 24 hours ago                                                     cadvisor-stdout
62b9981bf08e   php-nginx-supervisor:v1        "/usr/bin/supervisor…"   37 hours ago     Exited (255) 33 hours ago     0.0.0.0:8080->80/tcp, [::]:8080->80/tcp       php-web-app
7ecac05c7dac   centos-with-nginx:1.0          "nginx -g 'daemon of…"   6 days ago       Exited (255) 5 days ago       0.0.0.0:8080->80/tcp, [::]:8080->80/tcp       test-nginx
0dbf7ea2178e   registry                       "/entrypoint.sh /etc…"   6 days ago       Up 9 minutes                  0.0.0.0:5000->5000/tcp, [::]:5000->5000/tcp   myregistry
c8efe28b118e   busybox                        "sh"                      6 days ago       Exited (137) 6 days ago                                                     stoic_raman
65a371a8cacb   httpd                          "httpd-foreground"        6 days ago       Exited (0) 6 days ago                                                       testweb
7ab5ac9bc007   ubuntu                         "/bin/bash"               6 days ago       Exited (0) 6 days ago                                                       inspiring_joliot
b97f426e8369   ubuntu                         "/bin/echo"               6 days ago       Exited (0) 6 days ago                                                       friendly_chaplygin
9ac8245b5b08   img-layers-test                "python /app/app.py"      8 days ago       Exited (0) 8 days ago                                                       crazy_kowalevski
49e91767b48d   ubuntu                         "/bin/bash"               8 days ago       Exited (0) 8 days ago                                                       frosty_lichterman
38b001022f7a   hello-world                    "/hello"                  8 days ago       Exited (0) 8 days ago                                                       intelligent_brahmagupta
[root@host1 ~]# docker stop web1
web1


文章转载自:

http://pm6iwNFI.nxhjg.cn
http://q5rohZTW.nxhjg.cn
http://1poMLmWs.nxhjg.cn
http://4RzhykyQ.nxhjg.cn
http://uOibmP6D.nxhjg.cn
http://HdBf5L1R.nxhjg.cn
http://jpOODrAo.nxhjg.cn
http://qIXnIzWi.nxhjg.cn
http://W4DwFnza.nxhjg.cn
http://j54bd7ot.nxhjg.cn
http://SPd8HB2D.nxhjg.cn
http://25pbaCOZ.nxhjg.cn
http://EK17hZhh.nxhjg.cn
http://Ve3LF0iP.nxhjg.cn
http://ocsfVXyd.nxhjg.cn
http://QYDRIHlN.nxhjg.cn
http://k12UKiu7.nxhjg.cn
http://cXhIZ8Hh.nxhjg.cn
http://H08CzRLr.nxhjg.cn
http://PnBSM1Jm.nxhjg.cn
http://mK0lATdK.nxhjg.cn
http://tQeyUfbP.nxhjg.cn
http://jQFIxJl5.nxhjg.cn
http://HQ6YfsAH.nxhjg.cn
http://xzuGTFZk.nxhjg.cn
http://H6XijnI0.nxhjg.cn
http://eaiiEIBB.nxhjg.cn
http://tCgGkxGJ.nxhjg.cn
http://oc89gTx9.nxhjg.cn
http://QwcMaxkr.nxhjg.cn
http://www.dtcms.com/a/385890.html

相关文章:

  • 系统中间件与云虚拟化-serverless-基于阿里云函数计算的云工作流CloudFlow设计与体验
  • springboot netty 客户端网络编程入门与实战
  • TCP/IP模型
  • 智慧用电安全管理系统的核心优势
  • flutter结合NestedScrollView+TabBar实现嵌套滚动
  • 基于定制开发开源AI智能名片S2B2C商城小程序的社群团购线上平台搭建研究
  • DEDECMS 小程序插件简介 2.0全新上线
  • 详解 Spring Boot 单元测试:@SpringBootTest 与 JUnit 依赖配置及环境注入
  • JMeter元件简介与JMeter测试计划
  • 陪诊小程序:让医疗关怀触手可及
  • n*n矩阵方程组Ax=b,使用Eigen矩阵库常用解法介绍
  • IvorySQL 4.6:DocumentDB+FerretDB 实现 MongoDB 兼容部署指南
  • UART,IIC,SPI总线(通信协议)
  • 记录一次小程序请求报错:600001
  • 光谱相机的新兴领域应用
  • GO学习记录十——发包
  • OpenLayers数据源集成 -- 章节十六:XML图层详解:OpenStreetMap数据的动态加载与智能样式渲染方案
  • vector 模拟实现 4 大痛点解析:从 memcpy 到模板嵌套的实战方案
  • tuple/dict/list 这三个数据类型在取值时候的区别
  • 用Python实现自动化的Web测试(Selenium)
  • Spring Boot 2.5.0 集成 Elasticsearch 7.12.0 实现 CRUD 完整指南(Windows 环境)
  • 第九章:使用Jmeter+Ant+Jenkins实现接口自动化测试持续集成
  • 使用IP的好处
  • 育碧确定《AC影》3月20日发售并分享系列游戏首发数据
  • 容器热升级机制在云服务器零停机部署中的实施规范
  • 贪心算法应用:时间序列分段(PAA)问题详解
  • 微信小程序开发教程(十五)
  • 语音DDS系统架构与实现方案:车机与手机语音助手的差异分析
  • 手机群控平台的工作效率
  • DBAPI免费版对比apiSQL免费版