dongxiaoying5882
2017-06-18 22:22
浏览 471

Docker容器在本地连接到MySQL数据库 - >重定向到另一个容器

I am new to Docker.

I have read that it is better to keep an app per container.

I need to run web app (LAMP stack). So I have found the container for running PHP + Apache.

Now I need to set up a mysql container. But I am not sure what is the correct way to do that.

I read that it is possible to connect multiple containers together.

The idea is to make it trasnparent to the container running PHP + Apache when it tries to connect to mysql database locally.

But redirect all local connections to another container.

Another idea I have is to provide environment variable with host where should all connections go. In this case I need to have publicly accessible mysql server, but I need to keep it private and accessible only locally.

Could you please suggest a better option to choose in my case ?

Thank you

图片转代码服务由CSDN问答提供 功能建议

我是Docker的新手。 </ p>

我读过每个容器最好保留一个应用程序。 </ p>

我需要运行Web应用程序(LAMP堆栈)。 所以我找到了运行PHP + Apache的容器。 </ p>

现在我需要设置一个mysql容器。 但我不确定这样做的正确方法是什么。</ p>

我读到可以将多个容器连接在一起。 </ p>

当它尝试在本地连接到mysql数据库时,它的目的是使它对运行PHP + Apache的容器变得简单。</ p>

但重定向所有本地 与另一个容器的连接。</ p>

我的另一个想法是提供环境变量和主机应该在哪里连接。 在这种情况下,我需要有一个可公开访问的mysql服务器,但我需要将其保密并且只能在本地访问。</ p>

请问你能建议一个更好的选择吗? </ p>

谢谢</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题