Docker used in SpringBoot (using dockerfile-maven-plugin plug)

         Weekend at home to do an experiment:

  1. The Docker integrated into the plug by way of SpringBoot in
  2. Then Maven according to the project in order Dockerfile automatically generated Docker image, while the image pushed to the remote Linux server (remote server has been installed ahead of the Docker )
  3. Then the server by starting Docker to start SpringBoot projects, and access interface.

 

First step: Docker integrated into the plug by way of SpringBoot in

 Project structure

 

 

Meanwhile, the need to give permission to open the plug-in (otherwise will encounter refuse , 0.0.0.0 and other issues), in Maven 's pluginGroups node, add the following:

 

 

Dockerfile content:

 

 

Opening the server DockerAPI , so that I can push the mirror from the machine will go to the server.

 

 

将服务器和DockerAPI的地址配置到环境变量中:

 

 

 

第二步:然后通过Maven命令根据项目中的Dockerfile自动生成Docker镜像并推送到Linux服务器

 

 

 

另外,注意,我的项目中碰到了找不到main-class的问题,所以,我在这里指定了main-class.

 

 

上面就我是我们上传的镜像。

 

我在这中间碰以了invalid or corrupt jarfile的错误,网上说是改MATA-INFO里面的文件,但我的问题不是这样,我是Dockerfile中间的内容写错了,每个人碰到的问题都不一样,所以,别人的场景未必适合你,需要进行斟酌。

 

第三步:然后在服务器通过启动Docker来启动SpringBoot项目,并访问接口。

 

以下是在Linux本机访问(有时无法访问的会出现另外一些问题,比如防火墙未关闭等,这个可以参看网上的文章)。

 

 

远程访问。

 

 

Guess you like

Origin www.cnblogs.com/gudi/p/11074927.html