docker development specification
Using Docker to simplify development (optional)
前提:把spring-boot-starter-tomcat依赖的provided scope注释掉(如果不注掉,通过java命令运行项目时会因缺少jar包无法成功启动)
Building and running a Docker image of your application
To build a Docker image of your application without Docker and push it directly into your Docker registry, run:
mvn compile jib:build -Djib.to.image=myregistry/myimage:latest -Djib.to.auth.username=$USERNAME -Djib.to.auth.password=$PASSWORD
To build a Docker image of your application using Jib connecting to the local Docker daemon:
mvn compile jib:dockerBuild
To run this image, use the following docker run command:
docker run -itd -p 8080:8080 visualize
Using Docker Compose to simplify development (optional)
前提:已生成image
To run this image, use the Docker Compose configuration located in the src/main/docker folder of your application:
docker-compose -f src/main/docker/app.yml up -d
This command will start up your application and the services it relies on(database, redis…).
Build an image tarball(run image in production)
You can build and save your image to disk as a tarball with:
mvn compile jib:buildTar
This builds and saves your image to target/jib-image.tar, which you can load into docker with:
docker load --input target/jib-image.tar
还没有评论,来说两句吧...