How to use docker to build multiple php development environments on the same machine?

for example, I want to build three sets of the same php development environment on one machine. The domain name of the host is http://dev.xxx.com, and then I visit the address of the first environment: http://dev.xxx.com:8081. The address to visit the second environment is http://dev.xxx.com:8082, and the address to access the third environment is: http://dev.xxx.com:8083. The purpose of this is to do a dev development environment, a test environment, and a beta test environment.

ask God docker to tell us how to achieve it. Thank you!


you use web servers, such as nginx, to deploy different development environments according to the configuration of different ports and project directories.


you can directly create three containers with docker, deploy three LNMP environments, and then listen to different ports.


you can directly create three sets of php+nginx+mysql (+ redis) containers and listen to different ports. Every set is nginx, link php,php, link mysql and redis. Then each set is non-interfering with each other, so I suggest you take a look at the blog about docker building lnmp.


first of all, a container should contain complete programs and dependencies (outbound middleware). Take LNMP as an example: docker provides a Linux environment, and the container contains Nginx and Php, and then deploy a separate MySQL

.

secondly, if you have multiple environments, you can use multiple containers. You can simply use the-p parameter plus the port to distinguish the environment. For web programs, you can also distinguish the environment through the domain name (the following figure is for reference only. It is not recommended to put the production environment and development environment on the same machine):

                    +---------+  +--------------+       +--------------------+
                    |         |  |              |       |                    |
                    |         |  |    Dev       +------>+                    |
 http://dev.xxx.com |         |  |              |       |                    |
+------------------->         |  +--------------+       |     DB for Dev     |
                    |  Nginx  |                         |                    |
                    |         |  +--------------+       |     DB for test    |
 http://test.xxx.com|  Proxy  |  |              |       |                    |
+------------------->         |  |    Test      +------>+                    |
                    |         |  |              |       |                    |
                    |         |  +--------------+       +--------------------+
 http://prod.xxx.com|         |
+------------------->         |  +--------------+       +--------------------+
                    |         |  |              |       |                    |
                    |         |  |    Prod      +------>+     DB for prod    |
                    |         |  |              |       |                    |
                    +---------+  +--------------+       +--------------------+

refer to this article: https://blog.ihypo.net/148480...

containers for development environments only need to be deployed with VIRTUAL_HOST= http://dev.xxx.com
test environment in containers http://test.xxx.com

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be485f-39ab0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be485f-39ab0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?