Docker: Simplest Practice Notes

WBOY
Release: 2016-07-29 09:07:34
Original
890 people have browsed it

Start the handover today and sort out some things.

Environment:
Docker: Simplest Practice Notes

Several images have been installed, including Tomcat, etc.
Docker: Simplest Practice Notes

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>
Copy after login

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>
Copy after login

-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>
Copy after login

-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>
Copy after login

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>
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template