[docker] dockerfile publishes springboot project

1. Implementation steps

  • 1. Define the parent image: FROM java:8
  • 2. Define author information: MAINTAINER: learn_docker<https://www.docker.com>
  • 3. Add the jar package to the container: ADD jar package name.jar app.jar
  • 4. Define the container to start the execution command: CMD java -jar app.jar
  • 5. Build the image through dockerfile: docker build -f dockerfile file path -t image name: version

Two, examples

  • 1. Upload a jar package to the directory
    insert image description here

  • 2. Edit the dockerfile in the same directory

vim springboot_dockerfile

输入内容:
FROM java:8
MAINTAINER wangyouhui <https://www.docker.com>
ADD springboot-1.0-SNAPSHOT.jar app.jar
CMD java -jar app.jar

insert image description here

  • 3. Execute the build command
docker build -f ./springboot_dockerfile -t app .

insert image description here

  • 4.docker images view
    insert image description here
  • 5.docker run run
docker run -id -p 8080:8080 app

insert image description here

  • 6. Screenshot of the result
    insert image description here

  • 7. View the container

docker ps -a

insert image description here

Guess you like

Origin blog.csdn.net/qq_32088869/article/details/132112966