Home > Article > Operation and Maintenance > 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
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/
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
Start an existing container
docker start containerID/containerName docker start admiring_turing
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
Restart a container
docker restart containerID/containerName docker restart admiring_turing
Interactively operate with a started container
docker exec -i -t containnerID/containerName /bin/bash docker exec -i -t admiring_turing /bin/bash
Copy files to the container
docker cp src_path container:dest_path docker cp /test.txt admiring_turing:/usr/local/
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
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!