Home >Backend Development >PHP Tutorial >Docker: Simplest Practice Notes
Start the handover today and sort out some things.
Environment:
Several images have been installed, including Tomcat, etc.
Create a directory to make an image with a WEB application, such as sys-webapp:
Go into this directory and create a Dockerfile with the following content:
<code>FROM tomcat:latest COPY sys<span>.war</span> /usr/local/tomcat/webapps/sys<span>.war</span> CMD [<span>"catalina.sh"</span>,<span>"run"</span>] </code>
Then, upload our sys.war to the current directory via SFTP. Execute the following command (note that there is a dot after it, the current directory):
<code>docker build <span>-t</span> tomcat/sys<span>-webapp</span><span>.</span></code>
-t specifies the label. This will generate a new Image, which can be viewed with the docker images command.
The running command is as follows:
<code>docker run <span>-d</span><span>--</span>name sys <span>-p</span><span>8000</span>:<span>8080</span> tomcat/sys<span>-webapp</span></code>
-d runs in the background, –name gives a name for future operations, -p specifies port mapping (local port: container port), and then the name of the image.
Now, we can access the 10.250.251.20:8000 port to see the application we deployed.
Use this image to start a container, and the port mapping is 8001, with the following command:
<code>docker run <span>-d</span><span>--</span>name sys2 <span>-p</span><span>8001</span>:<span>8080</span> tomcat/sys<span>-webapp</span></code>
Then, we configure a pool in Nginx:
<code>upstream sys-webapp-pool { ip_hash; <span>server</span><span>10.250</span><span>.251</span><span>.20</span>:<span>8000</span>; <span>server</span><span>10.250</span><span>.251</span><span>.20</span>:<span>8001</span>; } </code>
In fact, the use of Docker is very convenient, but in practice, We still have some things that need to be configured, such as specifying how many cores of the CPU the image can use when building, limiting memory, etc.
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above introduces Docker: the simplest practical notes, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.