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 deploy Java web system with Docker

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to deploy the Java web system with Docker". In the daily operation, I believe many people have doubts about how to deploy the Java web system with Docker. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to deploy the Java web system with Docker". Next, please follow the editor to study!

Docker deploys java web system

1. Create a path test/app mkdir test&& cd test&& mkdir app & & cd app under the root directory

two。 Copy apache-tomcat-7.0.29.tar.gz and jdk-7u25-linux-x64.tar.gz to the app directory

3. Extract two tar.gz files

Tar-zxvf apache-tomcat-7.0.29.tar.gz tar-zxvf jdk-7u25-linux-x64.tar.gz

4. Rename the decompressed file

Mv apache-tomcat-7.0.29 tomcat mv jdk-7u25-linux-x64 jdk

5. In the app directory, create a dockerfile file to create an image

Touch dockerfile

6.dockerfile document content and comments

-dockerfile content--

# use ubuntu:14.04 as the basic image from ubuntu:14.04# to specify the image creator information maintainer test xxxx@xxx.com# creation date env refreshed_at 2017-2-switch the image directory, enter the / usr directory workdir / usr#, create a jdk directory under / usr/, and use it to store jdk files run mkdir jdk# create a tomcat directory under / usr/ It is used to store the directory of the tomcat run mkdir tomcat# switched image to / usr/jdk workdir / usr/jdk/#. Copy the files under the host's jdk directory to the mirror's / usr/jdk directory. Add jdk/ usr/jdk# switch the image's directory to / usr/tomcat workdir / usr/tomcat#. Copy the files under the host's tomcat directory to the mirror's / usr/tomcat directory. Set the add tomcat / usr/tomcat# environment variable env java_home=/usr / jdk env java_bin=/usr/jdk/bin env path=$path:$java_home/bin env classpath=.:$java_home/lib/dt.jar:$java_home/lib/tools.jar# switch working directory to root workdir / usr/tomcat/webapps/root# delete tomcat default project file run rm-rf * # add your own xxx.war system to the root directory under tomcat in the docker image add webapp / usr/tomcat/webapps/xxx.war# publishes 8080 of tomcat Port expose 808 starts tomcat entrypoint [".. /.. / bin/catalina.sh" "run"]

7. Create a mirror through dockerfile

Command:

Docker build-t image name: label dockerfile location docker build-t tms:1.0. (. Represents the current directory)

8. At this point, the java web system is made into an image and verified by docker images.

9. Start a docker container by just building an image

Command: docker run-d-p host mapping port: container exposure port-- name container name image name / image id

-d parameter: backend startup mode

-p parameter: mapping between host port and container port

-- name parameter: give the container an individual name

Docker run-d-p 8081 name 8080-- name container name image name: image tag

10. Verify by docker ps-a

At this point, the study on "how to deploy the Java web system with Docker" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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