How to deploy war package to docker

angryTom
Release: 2020-03-31 16:07:36
Original
4163 people have browsed it

How to deploy war package to docker

How to deploy the war package to docker

The method of placing the war package into tomcat under docker is as follows:

1. First, you need to put the war package into the centos system. In this article, a test.war project is placed into the main directory of the centos system. This can be placed into centos through the ssh tool. Everyone should be familiar with it. Familiar, the format is as follows:

scp local_file remote_username@remote_ip:remote_folder
Copy after login

2. Move test.war from centos to the container started by the tomcat image under docker.

(Related video tutorial sharing: java video tutorial)

docker cp test.war containerID:/usr/local/tomcat/webapps/
Copy after login

Description:

containerID is the container ID or container name of the tomcat image you started That's ok too.

This is to put test.war under tomcat's webapps

Common docker commands

For the convenience of understanding, here we take the tomcat image as an example . One line of syntax description and one line of examples.

Generate a container through the image

docker run -p port1:port2 containerName:tag
docker run -p 8080:8080 tomcat:latest
Copy after login

Start an existing container

docker start containerID/containerName
docker start admiring_turing
Copy after login

Among them, admiring_turing is the name of a container created by the tomcat image, and its container ID can also be used

Stop a container

docker stop containerID/containerName
docker stop admiring_turing
Copy after login

Restart a container

docker restart containerID/containerName
docker restart admiring_turing
Copy after login

Interactively operate with a started container

docker exec -i -t containnerID/containerName /bin/bash
docker exec -i -t admiring_turing /bin/bash
Copy after login

Copy files to the container

docker cp src_path container:dest_path
docker cp /test.txt admiring_turing:/usr/local/
Copy after login

test.txt is a test file created by myself and copied to the /usr/local directory of the container.

Running a container in the background

docker run -d -p image:tag
docker run -d -p tomcat:latest
Copy after login

For more related tutorials, please pay attention to the docker tutorial column on the PHP Chinese website.

The above is the detailed content of How to deploy war package to docker. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!