简体   繁体   English

不同Docker容器上的Rails和Nginx(如何在容器之间共享数据)

[英]Rails and Nginx on different Docker containers (how share data between containers)

I want to know if it's possible (or even a good practice) to run a Rails app and Nginx on different Docker containers. 我想知道是否有可能(甚至是一个好的做法)在不同的Docker容器上运行Rails应用程序和Nginx。

My intention is to use one instance of Nginx to serve more than one application running in containers in the future. 我的意图是将来使用Nginx的一个实例来为容器中运行的多个应用程序提供服务。

My question is because I will have to configure Nginx to access the root path of an application running on another container (I will have on my nginx.conf: root /home/user/public_html/railsapp/public/; ) 我的问题是因为我将必须配置Nginx来访问在另一个容器上运行的应用程序的根路径(我将在我的nginx.conf上使用: root /home/user/public_html/railsapp/public/;

How can I setup my rails docker container so the nginx container will be able to access the railsapp root path? 如何设置我的rails docker容器,以便nginx容器能够访问railsapp根路径?

The question is whether your rails application and the nginx will be two different processes or one? 问题是您的rails应用程序和nginx是两个不同的进程还是一个?

In case of two, you will have rails app served somehow and nginx proxying it. 如果是两个,您将以某种方式提供rails应用程序并通过nginx代理它。 Which is normal to run in two different containers. 在两个不同的容器中运行是正常的。

In case you will be serving your rails app by nginx, there is no need to create a separate container. 如果您要通过nginx提供Rails应用,则无需创建单独的容器。 You might just add files to the container of the nginx, use volumes or data containers. 您可能只是将文件添加到Nginx的容器中,使用卷或数据容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM