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

JavaScript imitates Jingdong carousel effect

This article shares the specific code for JavaScr...

Methods and problems encountered in installing mariadb in centos under mysql

Delete the previously installed mariadb 1. Use rp...

Detailed explanation of Vue filters

<body> <div id="root"> <...

A problem with MySQL 5.5 deployment

MySQL deployment Currently, the company deploys M...

MySQL query optimization: a table optimization solution for 1 million data

1. Query speed of two query engines (myIsam engin...

How to configure anti-hotlinking for nginx website service (recommended)

1. Principle of Hotlinking 1.1 Web page preparati...

MySQL 5.7 Common Data Types

——Notes from "MySQL in Simple Terms (Second ...

How to use vue.js to implement drag and drop function

Preface Adding drag and drop functionality is a g...

Which scenarios in JavaScript cannot use arrow functions

Table of contents 1. Define object methods 2. Def...

Implementation of nacos1.3.0 built with docker

1. Resume nacos database Database name nacos_conf...

Solution to mysql login warning problem

1. Introduction When we log in to MySQL, we often...

Baidu Input Method opens API, claims it can be ported and used at will

The relevant person in charge of Baidu Input Metho...

Introduction to the use of base link tag base

<br />When you click the link, the web page ...