Implementation of Docker deployment of web projects

Implementation of Docker deployment of web projects

The previous article has installed the docker service. Now let’s continue to introduce how to deploy a web project.

1: Create a directory dock at random and prepare the following files:

2. Write Dockerfile, which can quickly build docker images

vi Dockerfile

Add the following configuration

FROM centos
MAINTAINER this is dock image <jsh>
ADD jdk1.8.0_191 /usr/local/java
ENV JAVA_HOME /usr/local/java
ENV JAVA_BIN /usr/local/java/bin
ENV JRE_HOME /usr/local/java/jre
ENV PATH $PATH:/usr/local/java/bin:/usr/local/java/jre/bin
ENV CLASSPATH /usr/local/java/jre/bin:/usr/local/java/lib:/usr/local/java/jre/lib/charsets.jar
ADD apache-tomcat-8.5.40 /usr/local/tomcat8
ENTRYPOINT ["/usr/local/tomcat8/bin/catalina.sh","run"]
ADD ./manager.war /usr/local/tomcat8/webapps
EXPOSE 8080

explain:
(1) FROM centos means obtaining the centos base image from the Docker official repository. (2) ADD jdk1.8.0_191 /usr/local/ adds the jdk in the current directory (the same level directory as the Dockerfile) to the /usr/local/ of the image. (3) ENV JAVA_HOME /usr/local/jdk1.8.0_191 sets the Java environment variable. (4) EXPOSE 8080 exposes the port to the outside for external access. (5) CMD /usr/local/tomcat8/bin/catalina.sh run is the command executed after the container is running. If there are multiple CMDs, only the last one is valid.

3. Build an Image

Command: docker build -t dock . (space after dock.) to complete the build automatically. dock identifies the image name

4. Run the container

Command: docker run -d -p 8060:8080 dock
-d means running the container in the background and returning the container ID
-p uses port mapping. 8060:8080 means mapping port 8080 of the container to port 8060 of the host.

View all running container commands: docker ps -all

5. Test deployment results

ip:8060 If the tomcat page appears, it means that the container has been started successfully.

This is the end of this article about the implementation of Docker deployment of web projects. For more relevant content about Docker deployment of web projects, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Implementation of Docker deployment of Tomcat and Web applications
  • An example of how to quickly deploy web applications using Tomcat in Docker
  • Docker container uses Jenkins to deploy web projects (summary)
  • Detailed explanation of how to use Docker to deploy a web project and package it into an image file
  • Docker learning notes: Docker deployment of Java web system

<<:  Detailed explanation of axios encapsulation and API interface management in React project

>>:  What is the relationship between Mapper sql statement fields and entity class attribute names

Recommend

Windows 10 is too difficult to use. How to customize your Ubuntu?

Author | Editor Awen | Produced by Tu Min | CSDN ...

Design perspective technology is an important capital of design ability

A design soldier asked: "Can I just do pure ...

How to install vncserver in Ubuntu 20.04

Ubuntu 20.04 has been officially released in Apri...

Complete steps to use samba to share folders in CentOS 7

Preface Samba is a free software that implements ...

Detailed explanation of Linux one-line command to process batch files

Preface The best method may not be the one you ca...

Introduction to the functions and usage of value and name attributes in Html

1. The value used in the button refers to the text...

Where is the project location deployed by IntelliJ IDEA using Tomcat?

After IntelliJ IDEA deploys a Javaweb project usi...

MySQL 8.0.21 installation tutorial with pictures and text

1. Download the download link Click download. You...

View the frequently used SQL statements in MySQL (detailed explanation)

#mysql -uroot -p Enter password mysql> show fu...

MySQL Interview Questions: How to Set Up Hash Indexes

In addition to B-Tree indexes, MySQL also provide...

Vue local component data sharing Vue.observable() usage

As components become more detailed, you will enco...

Keep-alive multi-level routing cache problem in Vue

Table of contents 1. Problem Description 2. Cause...