简体   繁体   English

制作与旧容器具有相同配置的新容器

[英]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.

相关问题 当旧的docker容器达到指定的内存限制时,是否可以运行相同图像的新docker容器 - Is it possible to run a new docker container of same image when the old one reaches a specified memory limit 是启动一个现有的 Docker 容器还是总是运行一个新容器更好(并手动删除旧容器)? - Is it better to start an existing Docker container or always run a new one (and manually remove the old ones)? Docker 运行旧容器而不是我正在拉的新容器(AWS) - Docker runs old container instead of new one that I'm pulling (AWS) 旧文件保留在新的 docker 容器中 - Old files remain in new docker container Docker 继续使用已删除容器中的旧配置 - Docker keeps on using old configuration from deleted container 基于相同映像的新 docker 容器如何具有与以前相似的自定义文件? - How a new docker container based on the same image has custom files similar to a previous one? 如何将Docker网络从旧容器转移到新容器? - How to move docker network from old to new container? jenkins在运行新容器时使用旧数据 - jenkins use old data when running new container Traefik配置,以允许Websocket和https在容器的同一端口上 - Traefik configuration to allow websocket and https on the same port of a container 使 docker 容器在我的 VM 之外的同一网络上可用? - Making a docker container available outside my VM on the same network?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM