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

Implementation of Tomcat and Web applications deployed by Docker

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

First, download docker online

Yum install-y epel-releaseyum install docker-io # install dockerchkconfig docker on # join boot boot service docker start # start docker service

2. Docker installs Tomcat container

2.1. Find the tomcat information of the server

# docker search tomcat

2.2 download the official image with the highest Starts

Docker pull docker.io/tomcat

2.3 View all docker images

Docker images

2.4 start tomcat

Docker run-p 8081 8080 docker.io/tomcat # if the port is occupied, you can specify the mapping port of the container and the host the former is the peripheral access port and the latter is the internal port of the container

2.5 access to 192.168.138.132Rich 8080 after startup

3. Deploy your own web references

Docker ps # uses the following command to view running containers

3.1. Upload your own war package to the host

3.2. Execute to view the address in the container comcat

The one in the middle of docker exec-it 3cb492a27475 / bin/bash # is container id (CONTAINER_ID)

Throw the war packet to the host, throw it into the container, throw it into the tomcat/webapps.

Docker cp NginxDemo.war 3cb492a27475: / usr/local/tomcat/webapps

3.4. Start tomcat or restart docker restart [Container id]

Docker run-p 8081 8080 docker.io/tomcat

3.5 View mirroring started

Docker ps

3.6 execute View items in Container comcat

Docker exec-it 3cb492a27475 / bin/bash # the middle one is the container id (CONTAINER_ID) cd / webappsls # and you can see our project.

3.7 one drawback of the above execution is that the project will no longer be restarted after the container is restarted. Here is mode 2 startup by mounting.

Docker run-d-v / usr/docker_file/NginxDemo.war:/usr/local/tomcat/webapps/NginxDemo.war-p 8080 docker.io/tomcat

3.8 the first two methods are recommended to be used in the test environment, after all, the code should be modified frequently, and mode 3 can be used in production. It is also the way suggested by the official website.

Vi Dockerfile

From docker.io/tomcat:latest # Image of your tomcat MAINTAINER XXX@qq.com # author COPY NginxDemo.war / usr/local/tomcat/webapps # put it in tomcat's webapps directory

3.8.1 generate a new image:

Docker build-t nginx-demo:v1.

3.8.2 start a new mirror

Docker run-p 8080 8080 nginx-demo:v1

Other

# basic Information View docker version# View docker version number, including client, server, dependent Go and other docker info # View system (docker) level information, including managed images, number of containers, etc.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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

Servers

Wechat

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

12
Report