why why 2022-08-06 18:33:01 阅读数:11
Docker After building the container,The configuration is not easy to modify,This article records the method of modifying the folder mapping of the established container.
docker commit
命令生成镜像The benefit is a cure for all ailments,正规途径 The disadvantage is that the process is cumbersome,不够优雅
Container information such as port mapping is stored somewhere,Managed by configuration files,We only need to modify the port information of the configuration file to complete the rewriting
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
070465ca928b nextcloud "/entrypoint.sh apac…" 2 weeks ago Up 6 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp, 0.0.0.0:8443->443/tcp, :::8443->443/tcp nextcloud
CONTAINER ID
是070465ca928b
/data -> /data
的端口映射docker stop nextcloud
systemctl stop docker
/var/lib/docker/containers/{CONTAINER ID}
和
CONTAINER ID
Container-related configuration is in it ID in the corresponding subdirectory
cd /var/lib/docker/containers/070465ca928b...
# ls
5190850b4fcc...-json.log config.v2.json hostname mounts resolv.conf.hash
checkpoints hostconfig.json hosts resolv.conf
我们需要修改的是
hostconfig.json
和config.v2.json
两个文件
hostconfig.json
"Binds":["/data:/data"]
config.v2.json
"MountPoints":{"/data":{"Source":"/data","Destination":"/data","RW":true,"Name":"","Driver":"","Type":"bind","Propagation":"rprivate","Spec":{"Type":"bind","Source":"/data","Target":"/data"},"SkipMountpointCreation":false}
systemctl start docker
docker start nginx
copyright:author[why why],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/218/202208061814417763.html