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

MySQL infobright installation steps

Table of contents 1. Use the "rpm -ivh insta...

Sample code of uniapp vue and nvue carousel components

The vue part is as follows: <template> <...

Add unlimited fonts to your website with Google Web Fonts

For a long time, website development was hampered...

How to hide elements on the Web and their advantages and disadvantages

Example source code: https://codepen.io/shadeed/p...

Summary of Vue's cross-domain problem handling and solutions

When you send a network request, the following sa...

20 JavaScript tips to help you improve development efficiency

Table of contents 1. Declare and initialize array...

A comprehensive analysis of what Nginx can do

Preface This article only focuses on what Nginx c...

js drag and drop table to realize content calculation

This article example shares the specific code of ...

mysql5.7.17.msi installation graphic tutorial

mysql-5.7.17.msi installation, follow the screens...

Basic tutorial on controlling Turtlebot3 mobile robot with ROS

Chinese Tutorial https://www.ncnynl.com/category/...

How to find out uncommitted transaction information in MySQL

A while ago, I wrote a blog post titled "Can...

JS uses clip-path to implement dynamic area clipping function

background Today, I was browsing CodePen and saw ...