1, create a new folder, put the jar package in it, and create a new Dockerfile. The contents of the file are as follows:

FROM Java :8 VOLUME/TMP ADD projectName -0.0.1 -snapshot.jar app.jar RUN bash -c 'touch /app.jar' EXPOSE 8080 ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]Copy the code

2. CD Go to the newly created folder and run the following command

Docker build -t itmuch/ projectName :0.0.1 Build the mirror
docker images Viewing the Mirror List
## 3, Build complete, execute command
Docker run --name projectname -d -p 8080:8080 itmuch/projectname:0.0.1 Build and start the container
docker ps -a View a list of containers
## 4, other commands
docker stop containerid Stop the container
docker rmi imageid Remove the mirror
docker rm containerid Remove the container
docker logs -f containerid View real-time container running logs
systemctl start firewalld Start the firewall
firewall-cmd --zone=public --permanent --add-port=8080/tcp Open ports
firewall-cmd --reload Restarting the Firewall