如何在Docker映像中删除配置卷
我使用 docker run -it -v / xx1 -v / xx2 [image] / bin / bash
创建一个容器。
然后提交映像并推送到docker hub。
Then commit to image and push to docker hub.
使用 docker inspect [image]
音量
的详细信息是
"Volumes": {
"/xx1": {},
"/xx2": {}
},
现在,我要在此图像中删除卷 / xx1
。
Now I want to remove volume /xx1
in this image.
我该怎么办?
我认为使用Docker工具现在。您不能从正在运行的容器中删除卷,或者如果要将映像用作新Dockerfile中的基础,则不能删除继承的卷。
I don't think this is possible with the Docker tools right now. You can't remove a volume from a running container, or if you were to use your image as the base in a new Dockerfile you can't remove the inherited volumes.
可能的话,您可以使用JérômePetazzoni的 nsenter
工具手动删除容器内的安装架,然后提交。您可以使用该方法将卷附加到正在运行的容器,但是需要做一些相当低级的黑客操作。
Possibly you could use Jérôme Petazzoni's nsenter
tool to manually remove the mount inside the container and then commit. You can use that approach to attach a volume to a running container, but there's some fairly low-level hacking needed to do it.