如何将卷添加到现有的Docker容器? [英] How can I add a volume to an existing Docker container?
问题描述
sudo docker run - i -t ubuntu / bin / bash
我马上开始安装Java和其他一些工具,花一些时间与它并通过
exit
然后我想添加一个卷,意识到这并不像我以为会那么简单。如果我使用 sudo docker -v / somedir run ...
然后我最终得到一个新的新容器,所以我会安装Java并做我已经完成之前,才能到达带有安装卷的容器。
所有关于从主机安装文件夹的文档似乎都意味着安装卷可以是在创建容器时完成因此,我必须避免从头开始重新配置新容器的唯一选择是将现有容器提交到存储库,并将其用作新的容器的基础。
这是确实是向现有容器添加卷的唯一方法吗?
现在是的,唯一的方法是娱乐请参阅 Docker Pull Request 8484 ,以便我们期待动态添加功能。
I have a Docker container that I've created simply by installing Docker on Ubuntu and doing:
sudo docker run -i -t ubuntu /bin/bash
I immediately started installing Java and some other tools, spend some time with it and stopped the container by
exit
Then I wanted to add a volume and realised that this is not as straightforward as I thought it would be. If I use sudo docker -v /somedir run ...
then I end up with a fresh new container, so I'd have install Java and do what I've already done before just to arrive at a container with a mounted volume.
All the documentation about mounting a folder from the host seems to imply that mounting a volume is something that can be done when creating a container. So the only option I have to avoid reconfiguring a new container from scratch is to commit the existing container to a repository and use that as the basis of a new one whilst mounting the volume.
Is this indeed the only way to add a volume to an existing container?
For now yes, the only way is recreation. See Docker Pull Request 8484 for when we can expect the dynamic adding functionality.
这篇关于如何将卷添加到现有的Docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!