dockerfile - docker-compose每次up之后,之前在容器中所做的修改保不保留?
世界只因有你
世界只因有你 2017-04-27 09:02:11
0
2
1088

我测试的是保留的,比如我在mysql镜像数据库里新建了一个表,
重新docker-compose up以后,之前的表还存在,
不过没法理解啊,难道docker-compose up不是重新生成了镜像的实例吗?
每个docker-compose.yml其实只能生成一个实例?要reset的话必须手动删除之前的实例

世界只因有你
世界只因有你

reply all(2)
漂亮男人

docker-compose upPriority will be given to using existing containers instead of creating new ones.

The following method can solve your problem:

docker-compose up -d --force-recreate 使用 --force-recreate You can force the container to be rebuilt (otherwise the container will only be rebuilt when the container configuration changes)

docker-compose down Stop all containers and delete the container (so it will be a new container the next time you use docker-compose down 停止所有容器,并删除容器 (这样下次使用docker-compose up)

洪涛

docker-compose up is to create and start a container. As far as I know, there are only three situations where the container will be re-created (that is, the old container will be deleted first, and then a new one will be generated):
1. When the image is updated, the container will be re-created. Re-create the container;
2. The container does not exist (that is, it has been deleted);
3. When container A is re-created, the containers that depend on this container will be re-created (that is, the container in the docker-compose.yml file is set depends_on is the container of container A)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template