Dockerhub's php official image is as follows: hub.doc ker.com _ php instructions: as shown in the red box, it probably means that I can create a new Docerfile in the php code directory, then pack the code and the downloaded php image together to build a new image...
Docker hub php official Image https://hub.docker.com/_/php/
The usage instructions are as follows:
As shown in the red box,
This probably means that I should create a new Docerfile in the php code directory, and then pack the code and the downloaded php image together to build a new image. Does that mean?
The image is large, and why should it be put together? Isn't separation good?
I don't understand much. why am I wrong?
It is inconvenient to put the updated code together with php. isn't docker recommended to place each service separately? Why do we need to do this here? Please give me some explanations.
Reply content:
Docker hub php official Image https://hub.docker.com/_/php/
The usage instructions are as follows:
As shown in the red box,
This probably means that I should create a new Docerfile in the php code directory, and then pack the code and the downloaded php image together to build a new image. Does that mean?
The image is large, and why should it be put together? Isn't separation good?
I don't understand much. why am I wrong?
It is inconvenient to put the updated code together with php. isn't docker recommended to place each service separately? Why do we need to do this here? Please give me some explanations.
It seems that the subject does not quite understand the Docker running mode.
First, this is the process of using Dockerfile to build the image. First sentence
FROM php:5.6-cli
Indicates that this image was built from the officialphp:5.6-cli
Based on the image.
Okay, based on this Dockerfile, usedocker build
Command to build a new image.
A container is started based on an image. an image can start multiple containers.
COPY
Command to put the code of the current directory into the directory inside the container and setWORKDIR
For more information, see the official documentation.
LastCMD
Command is the bash command to be executed when the container starts.
Now, the general process is like this.
In terms of the working mechanism of Docker, after a container is started based on an image, it is isolated from the host machine. Therefore, you must put the code inside the container to use the internalPHP
Environment. To bypass the Federated file system, seeVOLUME
Command.
Docker is like this process. you need to re-place your code to an image. if you want to create a php7 image, you can see this: docker php7 image.
This probably means that I should create a new Docerfile in the php code directory, and then pack the code and the downloaded php image together to build a new image. Does that mean?
That's what you mean. it's okay with your understanding.
The image is large, and why should it be put together? Isn't separation good?
It can be separated or not separated, depending on your needs.
If it is not separated, COPY the folder in the Dockerfile. if it is separated, specify-v to mount the local folder when running the image.
For example, if you have an outsourcing project, you package the code in the image and then send the image to others. in this case, you do not need to separate it.
If you separate the code from the running environment during the development project, you can better develop the project. Otherwise, you need to package the code each time you change it.