docker文件存放路径, 获取容器启动命令 修炼js 7 es6新特性2 网页三栏布局常用方法 wordpress必须禁用REST API和移除WP-JSON链接的方法 面试官让我用纯css做一个下拉菜单,一分钟搞定!! CSS常用样式(二):绘制双箭头 住建部重申“房子是用来住的”;商务部公布禁塑时间表;在线旅游网站不得大数据杀熟 给大数据杀熟戴上“紧箍咒” RT-Thread推物联网操作系统!300秒启动安防摄像机 如何用一句话激怒程序员! 吉利在青岛成立物联网、卫星技术新公司 统计学和大数据之间有哪些联系 图说:九月开门红 大数据揭示A股九月行情走向 物联网时代下的“芯机遇”,「芯来科技」打造国产RISC-V生态 汇顶科技:指纹芯片巨头半年研发投入增八成,拓展物联网、汽车电子等领域应对风险 新华网|福州:树立物联网产业“马尾坐标” 「行走自贸区」福州:树立物联网产业“马尾坐标” k8s跨namespace访问服务 Mysql关键字和保留字(注意) ALTER command denied to user 'dev'@'192.168.10.xxx' for table 'xx_fanv_fail' oracle授权查询 ffmpeg vsync参数分析 小程序云函数中用group分组查询,只能查询20条,怎么解决? 【MyBatis&MyBatis-plus】分页查询避免两次查询同时返回总数和数据 数据库执行update语句没有反应,一直转圈,数据库锁表处理解决方法 按键精灵-自定义函数time(),datetime(),diff() 在Vue+Element中,Select选项值动态从后台接口获取的实现方法 mongoTemplate的方法和update() 欧科云链OKLink推出“链上天眼”功能 区块链+大数据全面助力链上安全 第二届微热点大数据论坛将于9月5日开幕 网龙参与全国教育大数据统计 构建五级服务支撑体系 无代码app制作崛起,app开发已不再是程序员的专利了 torch深入学习之凤飞九天torch.nn.MarginRankingLoss 【机器学习】—各类梯度下降算法 简要介绍 隐马尔可夫模型(HMM)来龙去脉(二) 单智能体、多智能体强化学习基本概念及算法分类?为啥提出多智能体强化学习,现状? 张量网络算法基础(八、张量网络机器学习【上】) MapReduce 简介 Python爬虫入门教程 81-100 小众爬虫框架looter,框架作者竟然在官方手册开车 机器人二维导航教程汇总 mapper 使用示例 Redis的概念及关系型与非关系型数据库对比 MySQL必知必会:使用WHERE、正则表达式、通配符过滤数据 Solr的增量更新和全量更新对比 MYSQL数据库维护 MATLAB与Mysql数据库连接并数据交换(基于ODBC) 数据库:PostgreSQL:基础功能使用介绍 MYSQL 5.7 高级SQL语句(3)——数据库函数和存储过程 mysql导出数据到表格讲解大全(导出数据带表头,导出数据中文乱码问题解决) SpringBoot升级/指定jackson版本
您的位置:首页 >开发 >

docker文件存放路径, 获取容器启动命令

文章目录

如何获取容器的启动命令1, 镜像层:文件存放路径2, 容器层:文件存放路径后天修改容器端口3, 进入镜容器文件存储目录, 修改配置文件4, 修改默认存储路径a, 重建/var/lib/docker目录b, 修改配置

如何获取容器的启动命令

容器早已创建好,如何得知它的启动参数(数据挂载到哪)
#假设通过如下命令启动了一个容器docker run-d--name mysql\-p 3306:3306\-e MYSQL_ROOT_PASSWORD=123456\--restart=always\mysql:5.5 --character-set-server=utf8#如何通过容器名得知启动参数[root@jenkins ~]# docker inspect mysql_cdh[{"Id": "fbc3fba81b57bc5b5871746098b5f1f7ef0ed7716a786584a5effbb88ba156e6","Created": "2019-09-25T01:43:37.720505875Z","Path": "docker-entrypoint.sh","Args": ["--character-set-server=utf8"], "HostConfig": {"Binds": ["mysql-data:/var/lib/mysql"],"ContainerIDFile": "","LogConfig": {"Type": "json-file","Config": {}},"NetworkMode": "default","PortBindings": {"3306/tcp": [{"HostIp": "","HostPort": "3306"}]},"RestartPolicy": {"Name": "always","MaximumRetryCount": 0},"Mounts": [{"Type": "volume","Name": "mysql-data","Source": "/var/lib/docker/volumes/mysql-data/_data","Destination": "/var/lib/mysql","Driver": "local","Mode": "z","RW": true,"Propagation": ""}],

1, 镜像层:文件存放路径

[root@master ~]# docker image inspect nginx |tail-n 22"GraphDriver": {"Data": {"LowerDir": "/var/lib/docker/overlay2/bf20cf788cc053f00ff1467525d50e19bd1cf07a2167f72511bdfcb28918a472/diff:/var/lib/docker/overlay2/317d80bb7ae58ed288be9ebd84aeb5b4b3a1c06f3211f5d1f32d89b629d1876e/diff","MergedDir": "/var/lib/docker/overlay2/7782d0eb292fdc8bbd73bf9bae2d65468e8aba0bcd6baed55ac348618b80ae16/merged","UpperDir": "/var/lib/docker/overlay2/7782d0eb292fdc8bbd73bf9bae2d65468e8aba0bcd6baed55ac348618b80ae16/diff","WorkDir": "/var/lib/docker/overlay2/7782d0eb292fdc8bbd73bf9bae2d65468e8aba0bcd6baed55ac348618b80ae16/work"},"Name": "overlay2"},

2, 容器层:文件存放路径

#1, 启动容器[root@master ~]# docker run -d --name nginx2 nginxa9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8#2, 获取容器id[root@master ~]# docker inspect nginx2| grep -i id [root@master ~]# docker inspect nginx2| grep -i id "Id": "a9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8","Pid": 2069,"ExecIDs": null,"ContainerIDFile": "",#查看容器临时文件--每次创建时随机生成的文件(容器层)[root@master ~]# docker inspect nginx2| grep -i path"Path": "nginx","ResolvConfPath": "/var/lib/docker/containers/a9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8/resolv.conf","HostnamePath": "/var/lib/docker/containers/a9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8/hostname","HostsPath": "/var/lib/docker/containers/a9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8/hosts","LogPath": "/var/lib/docker/containers/a9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8/a9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8-json.log", #通过容器id, 查找容器数据存放目录: /var/lib/docker/overlay2/容器id#######对比上面的“镜像层:文件存放路径”,可以看到 :容器通过LowerDir 挂载的方式,映射了镜像层的文件######[root@master ~]# docker inspect nginx2| grep -i dir"LowerDir": "/var/lib/docker/overlay2/d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b-init/diff:/var/lib/docker/overlay2/7782d0eb292fdc8bbd73bf9bae2d65468e8aba0bcd6baed55ac348618b80ae16/diff:/var/lib/docker/overlay2/bf20cf788cc053f00ff1467525d50e19bd1cf07a2167f72511bdfcb28918a472/diff:/var/lib/docker/overlay2/317d80bb7ae58ed288be9ebd84aeb5b4b3a1c06f3211f5d1f32d89b629d1876e/diff","MergedDir": "/var/lib/docker/overlay2/d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b/merged","UpperDir": "/var/lib/docker/overlay2/d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b/diff","WorkDir": "/var/lib/docker/overlay2/d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b/work"

后天修改容器端口

通过容器层文件,找到配置文件hostconfig.json,修改容器映射的端口

[root@docker d93185e3a0....2e544ccfa]# pwd/var/lib/docker/containers/d93185e3a0....2e544ccfa[root@docker d93185e3a0....2e544ccfa]# cat hostconfig.json {"Binds":["/dockersuperset:/home/superset"],"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"default","PortBindings":{"8088/tcp":[{"HostIp":"","HostPort":"8099"}]}......

3, 进入镜容器文件存储目录, 修改配置文件

# 进入镜容器文件存储目录, 修改配置文件[root@master ~]# cd /var/lib/docker/overlay2/d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# lsdifflinklowermergedwork[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls diff/run/nginx.pid[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls diff/var/cache/nginx/client_tempfastcgi_tempproxy_tempscgi_tempuwsgi_temp[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls merged/bin/dev/etc/lib/media/opt/root/ sbin/ sys/usr/boot/ .dockerenvhome/ lib64/mnt/proc/ run/srv/tmp/var/[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls merged/etc/nginx/conf.dfastcgi_paramskoi-utfkoi-winmime.typesmodulesnginx.confscgi_paramsuwsgi_paramswin-utf[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# head merged/etc/nginx/nginx.conf usernginx;worker_processes1;#在此处修改配置文件,把user nginx; worker_process 1; 这两行的分号去掉,看容器里面的配置是否更改[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# head merged/etc/nginx/nginx.conf -n 3usernginxworker_processes1#登陆容器,查看修改的配置: 验证是否生效[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# docker exec -it nginx2 bashroot@a9c9f31cdccf:/# head /etc/nginx/nginx.conf -n 3usernginxworker_processes1

4, 修改默认存储路径

a, 重建/var/lib/docker目录

#备份数据到新的存放路径service docker stopmkdir /docker.bakmv /var/lib/docker/*/docker.bak#创建软连接mkdir /home/docker-datamv /docker.bak/*/home/docker-data/ && rmdir /docker.bakln -s /home/docker-data/var/lib/docker

b, 修改配置

vi /usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/dockerd --graph /new-path/docker #reload配置文件 systemctl daemon-reload #重启docker systemctl restart docker.service

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。