使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

 

1、安装docker for mac, 官方安装教程,安装成功后启动docker

2、在IntelliJ IDEA中安装Docker integration插件        

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

3、安装插件后,需要配置连接docker服务端

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

4、创建Dockerfile文件,这个文件用于定义构建镜像的命令

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

5、运行tomcat镜像

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

6、配置上一步自动创建的Run/Debug configration

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

7、springboot 项目需要增加一个类,这个类需要和Application启动类同级.

使用IntelliJ IDEA把springboot web项目发布到docker容器中运行

8、运行配置好的Run/Debug configrations

 

9、手动构建镜像,我构建的镜像是要上传到阿里云镜像容器的,-t tagName ;   -f  contextDirectory(build artifact路径)

docker build -t registry.cn-hangzhou.aliyuncs.com/ns1/shuzhou:latest -f /Users/lufei/git_repo1/shuzhou/docker-dir/Dockerfile /Users/lufei/git_repo1/shuzhou/shuzhou-web/target/shuzhou-web