關於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的網站每次提交都顯示系統維護中,什麼鬼。。。。

相關文章
相關標籤/搜索