Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Dockerfile to run a simple Java program

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Dockerfile to run a simple Java program". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Dockerfile to run a simple Java program".

Prepare a java web project that has no third-party dependencies.

Upload the war package to the host directory on the server where the docker software is installed. Create the Dockerfile in the sibling directory.

Write the contents of Dockerfile files.

# basic image uses tomcat:7.0.88-jre8FROM tomcat:7.0.88-jre8# author MAINTAINER zp # to define environment variable ENV TOMCAT_BASE/ usr/local/tomcat# copy war package COPY. / session-web.war $TOMCAT_BASE/webapps/

Perform a build

Docker build-t test-web:latest.

If the build is successful, the hierarchical information and results of the build are displayed.

After a successful build, use the docker images command to see if the image exists locally.

Run Mirror

Docker run-name test-web-d-p 8888purl 8080 test-web:latest

Use netstat-an | grep 8888 to verify that the port is listening after startup.

Thank you for reading, the above is the content of "how to use Dockerfile to run a simple Java program". After the study of this article, I believe you have a deeper understanding of how to use Dockerfile to run a simple Java program, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report