2014-12-30 10:42
浏览 92


I have PHP web application and i want to convert it into docker.

I have these containers


I have source code in my host folder as /var/www/site1

Now when i launch nginx , then i can mount site1 to nginx as /usr/nginx/share/html

But i am not sure how does i link with PHP conainer. Can't i have stand alone PHP container with only PHP installed or I need to have some webserver along with PHP

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

我有 PHP Web应用程序,我想将其转换为 docker < /code>.



我的主机文件夹中的源代码为 / var / www / site1

现在当我启动nginx时,我可以挂载 site1 到nginx为 / usr / nginx / share / html

但我不确定如何与PHP conainer链接。 我不能单独安装PHP的PHP容器,或者我需要有一些网络服务器和PHP

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongluni0568 2014-12-31 13:27

    My view on docker containers is that each container typically represents one process. E.g. mysql or nginx as in your example. Containers typically communicates with each other using networking or via shared files in volumes.

    Each container runs its own operating system (typically specified in the FROM-section in your Dockerfile. In your case, you are suggesting that the nginx-container runs in one process with one operating system and that the php-libraries run in a different process (in a different os). I'm not sure if this is doable but it seems as if it is a strange way of doing things.

    My suggestion is that you create two containers:

    • nginx+php - this container holds the PHP installation as well as the Nginx-stuff
    • mysql - this container contains the database

    The container can communicate via classic networking or as linked containers.

    However, the PHP-files that you wish to execute (i.e. your website) should be dynamically mounted as a data volume on the nginx+php container or as data volume container.

    点赞 打赏 评论