Original article, welcome to reprint. Reprint please specify: reprint from IT people story, thank you! Docker’s Java container runs external Springboot-jar.

After learning Docker for so long, I finally started to practice it. All deployment modes use the way of Docker, and I feel very cool. Here I share the rich JAR package of Springboot.

Download the Java image

docker pull java:openjdk-8
Copy the code

spring boot

The packed rich JAR is placed in the specified directory.

  • Run a command to create a container

Internal path /opt/pj/business.jar container path /usr/business.jar Execute jar Java -jar /usr/business.jar to expose port -p

docker run -d  -v /opt/pj/business.jar:/usr/business.jar --name business java:openjdk-8 -p 8888:8888 java -jar /usr/business.jar

Copy the code

Every time you upgrade

  1. Stop stop container
  2. Replace the jar of /opt/pj/
  3. Start the start container



Docker Configuration parameter Description

  • Name is used for the name of the container and can include a label
  • Tags A set of tag parameters. Tags in name are stripped before they are applied. Default empty set (optional)
  • Dockfile is used to build the image Dockerfile file, which defaults to project.file(‘Dockerfile’) and must be a file object (optional)
  • Files List of files that need to be included in the Docker context (optional)
  • BuildArgs A Map set with String keys that sets the –build-arg parameter for the build command (optional)
  • Labels A Map set with String keys. This will set the –label argument to build command, default empty (optional)
  • Pull whether to pull the latest underlying image before building. The default is false. (optional)
  • NoCache specifies whether the –no-cache parameter is set at build time to build the image from scratch. The default is false. Now use the following command to build a Docker image (it is necessary to ensure that the Docker process in the current environment has been started) PS: In fact, it is relatively simple to summarize themselves, learn the knowledge to live.