java通过想法远程一键部署springboot到码头工人详解

  


  

  

<强> 1。码头工人的安装可以参考https://docs.docker.com/install/
  

  

<强> 2。配置码头工人远程连接端口
  

  

<代码> vi/usr/lib/systemd/system/docker.服务代码
  

  

找到ExecStart,在最后面添加- h tcp://0.0.0.0:2375,如下图所示

  

癹ava通过想法远程一键部署springboot到码头工人详解"

  

<强> 3。重启码头工人
  

  

<代码> systemctl daemon-reload
  systemctl开始码头工人
  

  

<强> 4。开放端口
  

  

<代码> firewall-cmd区=公共——添加一个端口=2375/tcp——永久
  

  

<强> 5。想法安装插件,重启

  

癹ava通过想法远程一键部署springboot到码头工人详解"

  

<强> 6。连接远程码头工人
  

  

(1)编辑配置

  

癹ava通过想法远程一键部署springboot到码头工人详解"

  

(2)填远程码头工人地址

  

癹ava通过想法远程一键部署springboot到码头工人详解"

  

(3)连接成功,会列出远程码头工人容器和镜像

  

  


  

  

<强> 1。创建springboot项目
  

  

,项目结构图

  

癹ava通过想法远程一键部署springboot到码头工人详解"

  

(1)配置pom文件
  

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt;项目xmlns=" http://maven.apache.org/POM/4.0.0 "   xmlns: xsi=" http://www.w3.org/2001/XMLSchema-instance "   xsi: schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”比;   & lt; modelVersion> 4.0.0   & lt; groupId> docker-demo   & lt; artifactId> com.demo   & lt; version> 1.0 -snapshot   & lt; parent>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-parent   & lt; version> 2.0.2.RELEASE   & lt; relativePath/比;   & lt;/parent>   & lt; properties>   & lt; project.build.sourceEncoding> UTF-8   & lt; project.reporting.outputEncoding> UTF-8   & lt; docker.image.prefix> com.demo   & lt; java.version> 1.8 & lt;/java.version>   & lt;/properties>   & lt; build>   & lt; plugins>   & lt; plugin>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-maven-plugin   & lt;/plugin>   & lt; plugin>   & lt; groupId> com.spotify   & lt; artifactId> docker-maven-plugin   & lt; version> 1.0.0   & lt; configuration>   & lt; dockerDirectory> src/main/docker   & lt; resources>   & lt; resource>   & lt; targetPath>/& lt;/targetPath>   & lt; directory> $ {project.build.directory} & lt;/directory>   & lt; include> $ {project.build.finalName} .jar   & lt;/resource>   & lt;/resources>   & lt;/configuration>   & lt;/plugin>   & lt; plugin>   & lt; artifactId> maven-antrun-plugin   & lt; executions>   & lt; execution>   & lt; phase> package   & lt; configuration>   & lt; tasks>   & lt;复制todir==皊rc/main/码头工人”文件“目标/$ {project.artifactId} - {project.version} $ $ {project.packaging} "祝辞& lt;/copy>   & lt;/tasks>   & lt;/configuration>   & lt; goals>   & lt; goal> run   & lt;/goals>   & lt;/execution>   & lt;/executions>   & lt;/plugin>   & lt;/plugins>   & lt;/build>   & lt; dependencies>   & lt; dependency>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-web   & lt;/dependency>   & lt; dependency>   & lt; groupId> org.springframework.boot   & lt; artifactId> spring-boot-starter-test   & lt; scope> test   & lt;/dependency>   & lt; dependency>   & lt; groupId> log4j

java通过想法远程一键部署springboot到码头工人详解