关于docker-compose一些小理解

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

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只会为每一个镜像维护一个实例,每次运行code

docker-compose up

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

docker run [images name]

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

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

相关文章
相关标签/搜索