docker development specification

该博客介绍了如何利用Docker简化Spring Boot应用程序的开发流程。首先,需要注释掉spring-boot-starter-tomcat的provided scope以避免运行时缺少依赖。然后,可以使用Maven的Jib插件构建并推送到Docker registry。此外,也可以通过Jib连接本地Docker守护进程来构建镜像,并使用`docker run`命令运行。对于开发,推荐使用Docker Compose,它能方便地启动应用及其依赖服务。最后,还提供了打包镜像为tarball并加载到Docker的方法。

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	
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值