Table of contents
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
-
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
- 3. Execute the build command
docker build -f ./springboot_dockerfile -t app .
- 4.docker images view
- 5.docker run run
docker run -id -p 8080:8080 app
-
6. Screenshot of the result
-
7. View the container
docker ps -a