帝王谷资源网 Design By www.wdxyy.com

容器早已创建好,如何得知它的启动参数(数据挂载到哪)

#假设通过如下命令启动了一个容器
docker run -d --name mysql-p 3306:3306-e MYSQL_ROOT_PASSWORD=123456--restart=alwaysmysql: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 nginx
a9c9f31cdccf13c3385f3de33443325d2e14d69458e6d679e54c8cf9e5ff24c8

#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]# ls
diff link lower merged work

[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls diff/run/
nginx.pid
[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls diff/var/cache/nginx/
client_temp fastcgi_temp proxy_temp scgi_temp uwsgi_temp

[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls merged/
bin/    dev/    etc/    lib/    media/   opt/    root/    sbin/    sys/    usr/    
boot/    .dockerenv home/    lib64/   mnt/    proc/    run/    srv/    tmp/    var/    

[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# ls merged/etc/nginx/
conf.d fastcgi_params koi-utf koi-win mime.types modules nginx.conf scgi_params uwsgi_params win-utf

[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# head merged/etc/nginx/nginx.conf 
user nginx;
worker_processes 1;

#在此处修改配置文件,把user nginx; worker_process 1; 这两行的分号去掉,看容器里面的配置是否更改
[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# head merged/etc/nginx/nginx.conf -n 3
user nginx
worker_processes 1

#登陆容器,查看修改的配置: 验证是否生效
[root@master d37ff828e63081be6fcfefc73891e7b455596cb921c8021fbf9571f330c0599b]# docker exec -it nginx2 bash
root@a9c9f31cdccf:/# head /etc/nginx/nginx.conf -n 3
user nginx
worker_processes 1

4, 修改默认存储路径

a, 重建/var/lib/docker目录
#备份数据到新的存放路径
service docker stop
mkdir /docker.bak
mv /var/lib/docker/* /docker.bak

#创建软连接
mkdir /home/docker-data
mv /docker.bak/* /home/docker-data/ && rmdir /docker.bak
ln -s  /home/docker-data /var/lib/docker
b, 修改配置
vi /usr/lib/systemd/system/docker.service 
ExecStart=/usr/bin/dockerd --graph /new-path/docker 

#reload配置文件 
systemctl daemon-reload 
#重启docker 
systemctl restart docker.service

补充知识:Docker 指定数据储存目录

Docker 指定储存目录(原参数 --graph 已经失效 。)

方法一

一、在 Docker 配置文件中配置 /etc/docker/daemon.json

下面的命令是在 daemon.json 文件没有内容的时候进行添加的。如果有内容,就需要

cat << EOF /etc/docker/daemon.json
{
  "data-root": "/mnt/docker-data"
}
EOF
systemctl restart docker

方法二

二、在启动参数中配置

vim /usr/lib/systemd/system/docker.service

在里面的EXECStart的后面增加后如下:

ExecStart=/usr/bin/dockerd --data-root='/home/docker'
systemctl daemon-reload
systemctl restart docker

以上这篇docker文件存放路径, 获取容器启动命令操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

标签:
docker,文件存放路径,容器启动命令

帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。