How to run a project with docker

How to run a project with docker

1. Enter the directory where your project war is stored

Edit the Dockerfile

vim Dockerfile

The content is as follows:

rom registry.docker-cn.com/library/tomcat

MAINTAINER heihezi [email protected]

COPY myproject.war /usr/local/tomcat/webapps

2. Build your own image

docker build -t myproject:latest .

As expected, the steps of building the image will be displayed, and the last line is

Successfully built b3f6ac3157ae

The last string is part of the image id.

At this point you can run docker images to view your image information

3. Run your own docker container

docker run -d -p 8888:8080 myproject

Here -d means running in the background, -p means specifying the port, and the following 8888:8080 means mapping the host's port 8888 to the docker's port 8080. If the operation is successful, an id will be printed out.

4. Access your own projects

Check whether Tomcat is started successfully

192.168.1.178:8888

Visit project (add project name)

192.168.1.178:8888/myproject

This is the end of this article about how to run projects with docker. For more information about how to run projects with docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

<<:  Implementation of MySQL asc and desc data sorting

>>:  Detailed explanation of JavaScript to monitor route changes

Recommend

Detailed installation process of nodejs management tool nvm

nvm nvm is responsible for managing multiple vers...

Vue realizes the function of uploading photos on PC

This article example shares the specific code of ...

How to create a trigger in MySQL

This article example shares the specific code for...

Simple usage of MySQL temporary tables

MySQL temporary tables are very useful when we ne...

Sqoop export map100% reduce0% stuck in various reasons and solutions

I call this kind of bug a typical "Hamlet&qu...

JavaScript implements asynchronous submission of form data

This article example shares the specific code of ...

Reasons why MySQL 8.0 statistics are inaccurate

Preface Whether it is Oracle or MySQL, the new fe...

Vue implements simple notepad function

This article example shares the specific code of ...

3 codes for automatic refresh of web pages

In fact, it is very simple to achieve this effect,...

FastDFS and Nginx integration to achieve code analysis

FastDFS & Nginx Integration: The tracker is c...

Install MySQL 5.7 on Ubuntu 18.04

This article is compiled with reference to the My...

Detailed explanation of mysql transaction management operations

This article describes the MySQL transaction mana...

Example of implementing text wrapping in html (mixed text and images in html)

1. Text around the image If we use the normal one...

Setting up a proxy server using nginx

Nginx can use its reverse proxy function to imple...