关于docker-compose一些小理解

最初对docker-compose up这个命令很疑惑,以为每次运行它都会生成新的容器实例。其实不是这样的
docker-compose的官网有这样一段话

Preserve volume data when containers are created

Compose preserves all volumes used by your services. When docker-compose up runs, if it finds any containers from previous runs, it copies the volumes from the old container to the new container. This process ensures that any data you’ve created in volumes isn’t lost.

它的意思大概是

docker-compose只会为每个镜像维护一个实例,每次运行

docker-compose up

的时候,compose会查找之前的容器,把旧容器的volume-data拷贝到容器中。除非手动用docker rm命令删除容器,否则CONTAINER ID不会发生改变。
这和

docker run [images name]

不一样,这个命令每次运行会新生成一个镜像的实例,即新容器,它们对应的CONTAINER ID也各不相同。

 提交重复了。。。。sf的网站每次提交都显示系统维护中,什么鬼。。。。

    原文作者:lynnic89
    原文地址: https://segmentfault.com/a/1190000008705489
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞