Thank you for the invitation, let me tell you about my plan, I hope it can bring some slight help to the subject.
First of all, you need to make it clear that one container and one process are completed through collaboration between multiple containers.
So, the following four containers are needed:
nginx
Function: Respond to web requests and process static files.
Image: No need to build it yourself, just pull the official image directly.
php-fpm
Function: Process PHP scripts.
Mirror: Since the project may rely on different extensions, you need to rely on the official image to build it yourself. In addition, composer support is required.
mysql
Function: database.
Image: No need to build it yourself, just pull the official image directly.
redis
Function: cache database.
Image: No need to build it yourself, just pull the official image directly.
Let’s talk about the construction of php-fpm image. You need to pay attention to the following points:
Just rely on the official php:7.0.12-fpm image. There is no need to build it from scratch. You can choose the version by yourself. Bugs in the latest version are not ruled out.
If it is not used as a toy, it is best not to use the alpine series of mirrors, although it is small and exquisite.
Of course, you may encounter GFW problems during the construction process. You can refer to my article to make some adjustments: Docker Practice (7): Improve Happiness
After building the image, multi-container management requires the use of orchestration tools docker-compose,所以还需要编写 docker-compose.yml file, a simple example (don’t forget to read the comments):
Okay, let me recommend this Laradock In addition, if you have difficulty reading English, you can read the dean’s article... Laravel Academy Of course, there are many things that can be referenced, I want to ask Better to ask damn Google
Thank you for the invitation, let me tell you about my plan, I hope it can bring some slight help to the subject.
First of all, you need to make it clear that one container and one process are completed through collaboration between multiple containers.
So, the following four containers are needed:
nginx
Function: Respond to web requests and process static files.
Image: No need to build it yourself, just pull the official image directly.
php-fpm
Function: Process PHP scripts.
Mirror: Since the project may rely on different extensions, you need to rely on the official image to build it yourself. In addition, composer support is required.
mysql
Function: database.
Image: No need to build it yourself, just pull the official image directly.
redis
Function: cache database.
Image: No need to build it yourself, just pull the official image directly.
Let’s talk about the construction of php-fpm image. You need to pay attention to the following points:
Just rely on the official
php:7.0.12-fpm
image. There is no need to build it from scratch. You can choose the version by yourself. Bugs in the latest version are not ruled out.If it is not used as a toy, it is best not to use the
alpine
series of mirrors, although it is small and exquisite.A simple dockerfile example:
Of course, you may encounter GFW problems during the construction process. You can refer to my article to make some adjustments: Docker Practice (7): Improve Happiness
After building the image, multi-container management requires the use of orchestration tools
docker-compose
,所以还需要编写docker-compose.yml
file, a simple example (don’t forget to read the comments):Some points to note:
Be sure to define the network.
nginx.conf, default.conf, php.ini is best defined by yourself and mounted into the container.
Don’t forget to set the time zone.
In this way, the default.conf file of nginx can be written like this:
At this point, the configuration work is completed. In the future, you only need to cd to your project directory to execute
You can start developing, isn’t it very simple?
Okay, let me recommend this
Laradock
In addition, if you have difficulty reading English, you can read the dean’s article...
Laravel Academy
Of course, there are many things that can be referenced, I want to ask Better to ask damn Google
Recommend laradock on Github, don’t forget to configure a domestic acceleration, otherwise the download will be very slow