[英]Making a new container with the same configuration as the old one
Let's say I make a container with some flags. 假设我制作了一个带有一些标志的容器。 For instance, 例如,
docker run -v my_volume:/data my_cool_image
Now, let's say my_cool_image
is updated to a new version. 现在,假设my_cool_image
已更新为新版本。 Is there a nice way to make a new container with the same -v
flag as the old one? 有没有一种好方法来制作一个与旧容器具有相同-v
标志的新容器? The container has been properly configured so that the data does not get stored in the container, so deleting the old container is not a concern. 容器已正确配置,因此不会将数据存储在容器中,因此不必担心删除旧容器。
The best solution I can find is to use docker-compose
, but that seems a bit silly for single-container systems. 我能找到的最佳解决方案是使用docker-compose
,但是对于单一容器系统来说似乎有点愚蠢。
I'd use a shell script or a Docker Compose YAML file. 我会使用Shell脚本或Docker Compose YAML文件。 (Compose isn't really overkill; if you add some error handling and write out one option per line for readability, the shell script and the YAML file wind up being about the same length.) (撰写并不是真正的矫kill过正;如果您添加一些错误处理并每行写出一个选项以提高可读性,则外壳程序脚本和YAML文件的长度大约相同。)
There's nothing built in to Docker that can extract the docker run
options from an existing container. Docker内置没有任何东西可以从现有容器中提取docker run
选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.