Resource file path problem during docker installation and deployment
When using docker, you will encounter such a situation, for example, some files such as image resources uploaded by users, it is definitely not appropriate to put them directly in the code, and if you use some soft links to link resources to other directories, you may be wrong When encountering PHP can find the directory, but nginx cannot find the directory, because the default www directory of nginx in the docker container is /usr/share/nginx/html/, and the default directory of php is /var/www, so it will cause Only one of the applications can be loaded when the file is loaded.Of course, this problem can be solved, and the sooner you know this problem, the sooner you can avoid performing some deployment operations and then modify it again.
The first solution is to unify the default directory names of nginx and php.Note that it must be the path where both containers exist; the second is to mount a directory with the same name when starting nginx and php, so that this directory can be stored The uploaded resources can also allow nginx to access this directory. Of course, the premise here is that the soft link has been used to remove the resource from the code folder.
In addition, we also encountered a little uncomfortable thing when using docker.For example, we loaded a mirror to build and started a container.At this time, if we want to update the startup command of the container, we must restart a new container.At this time, if it is in the container Some things such as php extensions are installed, I'm sorry, they are all lost, that is, the startup command cannot be changed dynamically! Even some changes that have no other impact, such as adding a mount directory, are quite annoying. But it is not without a solution.Remember to save a new image when you delete the container that is not used but will be used after the expansion and update. In addition, when you need to transfer files between docker and the host, you can use docker copy, but there is no mv cut command, use the following: