Docker: PHP7 image building problems

Source: Internet
Author: User
Tags docker hub
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-cliBased on the image.

Okay, based on this Dockerfile, usedocker buildCommand to build a new image.
A container is started based on an image. an image can start multiple containers.

COPYCommand to put the code of the current directory into the directory inside the container and setWORKDIRFor more information, see the official documentation.

LastCMDCommand 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 internalPHPEnvironment. To bypass the Federated file system, seeVOLUMECommand.

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.