Home > Article > Operation and Maintenance > How docker runs a project
1. Enter the directory where your project war is stored
Edit the Dockerfile file
vim Dockerfile
The content is as follows:
rom registry.docker-cn.com/library/tomcat MAINTAINER heihezi heihezi@foxmail.com COPY myproject.war /usr/local/tomcat/webapps
2. Build your own image
docker build -t myproject:latest .
As expected, the steps to build the image will be displayed. The last line is
Successfully built b3f6ac3157ae
and the last string is the image id. a part of.
You can run docker images at this time to view your own image information
3. Run your own docker container
docker run -d -p 8888:8080 myproject
Here -d is running in the background. -p is the specified port, and the following 8888:8080 is to map the 8888 port of the host to the 8080 port of docker. If the operation is successful, an id will be printed out
4. Access your own project
Check whether tomcat starts successfully
192.168.1.178:8888
Access the project (add project name)
192.168.1.178:8888/myproject
Recommended tutorial: docker tutorial
The above is the detailed content of How docker runs a project. For more information, please follow other related articles on the PHP Chinese website!