不使用run的方式进行volume挂载

修改配置文件:

当容器已经运行起来,不想重新run一个容器进行挂载,那么就使用修改容器的 config.v2.json的方式进行修改。

核心:修改配置文件来完成挂载

# 停掉 容器
[root@VM-16-5-centos ]# docker stop elasticsearch
[root@VM-16-5-centos ]# docker stop kibana

# 停掉 docker服务
[root@VM-16-5-centos ]# systemctl stop docker.service
Warning: Stopping docker.service, but it can still be activated by:
  docker.socket
  
# 打开 config.v2.json   地址在/var/lib/docker/containers/container-ID/config.v2.json
[root@VM-16-5-centos 75ea8289df86c6f27e9890dfe2995303c7c79e26df16e13092f444a7a6c1243f]# vim config.v2.json

# 在confi.v2.json中添加对应的MountPoints内容:
"MountPoints":{"/usr/share/elasticsearch/data_import":{"Source":"/var/lib/docker/volumes/elastic_data/_data","Destination":"/usr/share/elasticsearch/data_import","RW":true,"Name":"elastic_data","Driver":"local","Type":"volume","Relabel":"rw","Spec":{"Type":"volume","Source":"elastic_data","Target":"/usr/share/elasticsearch/data_import"},"SkipMountpointCreation":false}}

# 启动docker,启动容器
[root@VM-16-5-centos ]# systemctl start docker.service
[root@VM-16-5-centos ]# docker start elasticsearch

你可能感兴趣的:(不使用run的方式进行volume挂载)