[英]How to setup docker architecture
I'd like to have the following configuration: 我想要以下配置:
Docker Containers
|||||||||||| |||||||||||| ||||||||||||
| | | | | |
| | | | | |
| | <--> | | <--> | |
| | | | | |
| | | | | |
|||||||||||| |||||||||||| ||||||||||||
nginx web server postgres
With the following setup: 使用以下设置:
Nginx Nginx的
nginx.conf
更改nginx.conf
sites-available
entry 添加适当的sites-available
条目 sites-enabled
sites-enabled
链接配置sites-enabled
PostgreSQL PostgreSQL的
Web Server 网络服务器
I have a couple of questions as well: 我也有几个问题:
a) how to pass secrets to Docker like API keys, passwords and so on? a)如何将秘密 (例如API密钥,密码等)传递给Docker?
b) is this possible to clone repo from docker or there is other way to do that? b)是否可以从docker克隆存储库,或者有其他方法可以这样做?
c) how and where deploy such applications? c)如何以及在何处部署此类应用程序?
d) is that setup even possible? d)设置是否可行?
This setup is very common with docker. 此设置在docker中非常常见。 I'd recommend you look into using docker-compose ( example ) because it makes setting it up drastically easier. 我建议您考虑使用docker-compose( 示例 ),因为它可以大大简化设置过程。
Passing in secrets is done through environment variables at docker run time. 在docker运行时通过环境变量来传递秘密。 If you have many you can store them in an env-file. 如果数量很多,可以将它们存储在一个env文件中。
Yes, you can clone a repo from a docker container or during a docker build. 是的,您可以从Docker容器或在Docker构建期间克隆存储库。 Cloning a private repo during a docker build is currently not feasible (without exposing your credentials) so it's usually recommended to clone your repo before running docker build. 当前在docker构建期间克隆私有存储库是不可行的(不公开您的凭据),因此通常建议在运行docker build之前克隆您的存储库。
a) usually pass secrets through environment variables, this is easy for containers to use. a)通常通过环境变量传递秘密 ,这对于容器来说很容易使用。
b) yes, you can, if you want clone a public repo, you can do it in Dockerfile with RUN git clone repo
; b)是的,您可以,如果您要克隆公共仓库,则可以使用RUN git clone repo
在Dockerfile中完成; also you can pull you repo at Entrypoint
if you want make sure your repo is updated. 如果您想确保您的Entrypoint
已更新,也可以在Entrypoint
处Entrypoint
。
c) emm...I don't know how to answer this, maybe docker docs ? c)嗯...我不知道如何回答这个问题,也许是docker docs吗?
d) this setup is possible, but here is some advices: d)可以进行此设置,但是这里有一些建议:
Volume
to serve your web contents, so you can bind volume to nginx container and serve your static contents with nginx. 使用Volume
来提供您的Web内容,因此您可以将volume绑定到nginx容器,并使用nginx来提供您的静态内容。 This is piece of cake with Docker and Docker-Compose. 这是Docker和Docker-Compose的小菜一碟。 All you need are suitable containers where you can pass the parameters on startup. 您只需要合适的容器即可在启动时传递参数。 Afterwards the compose-template can be moved around and instanced multiple times. 之后,撰写模板可以四处移动和实例化。
The containers communicate through links and docker provides hostnames for handling changing ip addresses. 容器通过链接进行通信,泊坞窗提供用于处理更改的IP地址的主机名。
This is an example for setting up the Jira web application with a postgres database. 这是一个使用postgres数据库设置Jira Web应用程序的示例。 This should be analogous to your example. 这应该类似于您的示例。 An nginx server can be added as easily. 可以轻松添加nginx服务器。
jira:
image: blacklabelops/jira
ports:
- '8100:8080'
volumes:
- /opt/atlassian-home
environment:
- 'DATABASE_URL=postgresql://jiradb@postgresql/jiradb'
- 'DB_PASSWORD=jellyfish'
links:
- postgresql
postgresql:
image: sameersbn/postgresql:9.4-1
ports:
- '5432:5432'
environment:
- 'PSQL_TRUST_LOCALNET=true'
- 'DB_USER=jiradb'
- 'DB_PASS=jellyfish'
- 'DB_NAME=jiradb'
The Jira server will be available with localhost:8100 and the database will be available with localhost:5432 Jira服务器将在localhost:8100可用,数据库将在localhost:5432可用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.