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

How to create LVM for XFS file system in Ubuntu

Preface lvm (Logical Volume Manager) logical volu...

A brief discussion on the fun of :focus-within in CSS

I believe some people have seen this picture of c...

Solution to define the minimum height of span has no effect

The span tag is often used when making HTML web pa...

Using Zabbix to monitor the operation process of Oracle table space

0. Overview Zabbix is ​​an extremely powerful ope...

How to clear the validation prompt in element form validation

Table of contents Problem scenario: Solution: 1. ...

Design Story: The Security Guard Who Can't Remember License Plates

<br />In order to manage the vehicles enteri...

Detailed usage of Vue timer

This article example shares the specific code of ...

Vue component library ElementUI realizes the paging effect of table list

ElementUI implements the table list paging effect...

Reasons and solutions for slow MySQL query stuck in sending data

Because I wrote a Python program and intensively ...

Implement a simple search engine based on MySQL

Table of contents Implementing a search engine ba...

How to set up ssh password-free login to Linux server

Every time you log in to the test server, you alw...

CSS3 radar scan map sample code

Use CSS3 to achieve cool radar scanning pictures:...

Usage of mysql timestamp

Preface: Timestamp fields are often used in MySQL...

How to use the HTML form attributes readonly and disabled

1. readonly read-only attribute, so you can get th...