Docker Compose-部署中的符号链接 [英] Docker Compose - symlink in deployment
问题描述
我有一个具有此结构的应用程序。
I have an application with this structure.
-
/ path / releases
-
/ path / releases / 01012016
-
/ path /版本16012016
-
/ path / releases / etc ..
/path/releases
/path/releases/01012016
/path/releases/16012016
/path/releases/etc..
和
-
/ path / dev
(指向某些版本的符号链接) -
/ path / stag
(指向某些版本的符号) -
/ path / stable
(某些
版本的符号链接)
/path/dev
(symlink to some version)/path/stag
(symlink to some version)/path/stable
(symlink to some version)
我的docker-compose.yml看起来像这样:
My docker-compose.yml looks like this:
nginx:
...
volumes_from:
- data
php:
...
volumes_from:
- data
data:
volumes:
- /path/stable:/var/www
我知道Docker解决了符号链接。我认为在部署之前,我只是重新创建数据容器,这没关系。
I known that Docker resolves symlinks. I have thought before deploy I just recreate data container and it's ok. But it's not.
我必须重新创建从数据容器中获取卷的所有容器。
I have to recreate all containers taking volumes from data container.
任何想法如何使其变得更好,我的意思是更好的自动化?删除符号链接并将最新版本放入 docker-compose
?将父文件夹标记为卷,并通过相对符号链接解析它?或任何其他解决方案。
Any idea how to make it better, I mean better automatic? Remove symlinks and put last version to docker-compose
? Mark parent folder as volume and resolve it via relative symlink? Or any other solution.
哪种解决方案最适合您?最佳做法是什么。
Which solution is best for you. What's the best practice.
谢谢。 Felix
推荐答案
如果只想使其自动化,可以在一个docker-compose.yml中重新创建所有容器。使用 docker-compose up --force-recreate
。
If you just want to make it more automatic, recreating all the containers in one docker-compose.yml can be achieved with docker-compose up --force-recreate
.
另一种解决方案是:
/path:/var
…然后,当您要更改时,然后 ln -s / path / releases / 06012016 / path / www
。
…then ln -s /path/releases/06012016 /path/www
when you want to change.
我不太喜欢这种解决方案,因为它会将您所有的发布都暴露在容器中。我宁愿完全重启--force-recreate。
I don't like much this solution as it exposes all your releases inside your containers. I would rather go for the full restart --force-recreate.
这篇关于Docker Compose-部署中的符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!