Implementation of Docker deployment of Tomcat and Web applications

Implementation of Docker deployment of Tomcat and Web applications

1. Download docker online

yum install -y epel-release

yum install docker-io # Install docker

chkconfig docker on # Add service to boot docker start # Start docker service

2. Install Tomcat container with docker

2.1. Find the server's tomcat information

# 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 external access port: the latter is the internal port of the container 

這里寫圖片描述

2.5 After startup, you can access 192.168.138.132:8080

這里寫圖片描述

3. Deploy your own web reference

docker ps # Use the following command to view the running container 

這里寫圖片描述

3.1. Upload your own war package to the host

這里寫圖片描述

3.2. Execute and view the address in the container comcat

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

這里寫圖片描述

3.3 Drop the war package to the host machine, then drop it into the container and drop it into 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 Check if the image has been started

docker ps 

這里寫圖片描述

3.6 Execute and view the project in the container comcat

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

cd /webapps

ls # You can view our project

3.7 The above execution has a disadvantage that the project will no longer exist after the container is restarted. The following is method 2 to start by mounting

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

3.8 The first two methods are recommended to be used in a test environment, since the code needs to be modified frequently. Method 3 can be used in production. This is also the method recommended by the official website

vi Dockerfile

from docker.io/tomcat:latest #your tomcat image MAINTAINER [email protected] #author COPY NginxDemo.war /usr/local/tomcat/webapps #Place it in the webapps directory of tomcat 

這里寫圖片描述

3.8.1 Generate a new image:

docker build -t nginx-demo:v1 . 

這里寫圖片描述

3.8.2 Start a new image

docker run -p 8080:8080 nginx-demo:v1 

這里寫圖片描述

other

# Basic information View docker version

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

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • An example of how to quickly deploy web applications using Tomcat in Docker
  • Detailed explanation of Docker automatic deployment of tomcat
  • Detailed steps to deploy tomcat and java applications in docker
  • Use docker to deploy tomcat and connect to skywalking

<<:  VMware kali virtual machine environment configuration method

>>:  Using react+redux to implement counter function and problems encountered

Recommend

Vue.$set failure pitfall discovery and solution

I accidentally found that Vue.$set was invalid in...

The whole process of developing a Google plug-in with vue+element

Simple function: Click the plug-in icon in the up...

Markup Language - Title

Click here to return to the 123WORDPRESS.COM HTML ...

Detailed explanation of how to use the Vue license plate search component

A simple license plate input component (vue) for ...

Detailed explanation of nginx request header data reading process

In the previous article, we explained how nginx r...

Detailed explanation of MySQL 30 military rules

1. Basic Specifications (1) InnoDB storage engine...

Some indicators of excellent web front-end design

The accessibility of web pages seems to be somethi...

An article to understand what is MySQL Index Pushdown (ICP)

Table of contents 1. Introduction 2. Principle II...

The difference between html form submission action and url jump to actiond

The action of the form is different from the URL j...

MySQL data migration using MySQLdump command

The advantages of this solution are simplicity an...

A brief introduction to MySQL database optimization techniques

A mature database architecture is not designed wi...

How to reset the initial value of the auto-increment column in the MySQL table

How to reset the initial value of the auto-increm...