In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to mirror the war package in Dockerfile. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
1. Install the tomcat image
Docker search tomcat, querying various image names of tomcat
Docker pull tomcat:8.5.43, install the image using docker pull, we want to download version 8.5.43 here.
two。 Write the Dockerfile file FROM tomcat:8.5.43WORKDIR / usr/local/tomcat/webapps/RUN rm-rf * ADD web/ .EXPOSE 8080CMD ["/ usr/local/tomcat/bin/catalina.sh", "run"]
FROM specifies the base image
WORKDIR specifies the working directory in the container
RUN rm-rf * delete the contents under webapps in the container
ADD web/. There is a war package in the web directory. Copy the war package to the working directory of the container.
EXPOSE declares that the runtime container provides a service port
CMD specifies the default startup command for the container main process
3. Build an image
Docker build-t cosmos_service.
Build the image from the Dockerfile file with the name cosmos_service
At this point, execute docker images, and you can see the image you just built.
4. Start the container
Docker run-d-name webapp-p 8088 purl 8080 cosmos_service:latest
-d indicates that the container runs in the background and returns the container ID-- name gives the container a name-p p1:p2 p1 means external access port p2 indicates that the last parameter of the port in the container is the name of the image and tag
Enter the container
Docker exec-it 5c9da02e552587d9b52883a4fa612854b919303222f5ad5af0eac3a61e372381 / bin/bash
The container ID returned by 5c9da02e552587d9b52883a4fa612854b919303222f5ad5af0eac3a61e372381 for run-d
After entering the container, you can view the war package deployment of tomcat.
5. Some general commands use the
Docker stop webapp stops running Container webapp
Docker start webapp starts the container webapp that has been stopped
Docker rm webapp delete container
Docker images view all mirrors
Docker rmi 5a4980b77ef4 deletes a mirror whose ID is 5a4980b77ef4
After reading the above, do you have any further understanding of how to put the war package into the image in Dockerfile? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.