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 uses covering index to avoid table return and optimize query

Preface Before talking about covering index, we m...

Mysql join query syntax and examples

Connection query: It is the result of connecting ...

Detailed explanation of overflow-scrolling to solve scrolling lag problem

Preface If you use the overflow: scroll attribute...

The pitfall record of the rubber rebound effect of iOS WeChat H5 page

Business requirements One of the projects I have ...

A universal nginx interface to implement reverse proxy configuration

1. What is a proxy server? Proxy server, when the...

MySQL gets the current date and time function

Get the current date + time (date + time) functio...

5 ways to migrate from MySQL to ClickHouse

Data migration needs to be imported from MySQL to...

Query the data of the day before the current time interval in MySQL

1. Background In actual projects, we will encount...

css3 animation ball rolling js control animation pause

CSS3 can create animations, which can replace man...

Installation, configuration and use of process daemon supervisor in Linux

Supervisor is a very good daemon management tool....

How to try to add sticky effect to your CSS

Written in front I don’t know who first discovere...