介绍
这篇文章给大家介绍如何对弹簧引导与码头工人进行部署,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
<强>开启码头工人远程访问强>
首先需要开启码头工人远程访问功能,以便可以进行远程操作。
<强> CentOS 6 强>
修改/etc/违约/码头工人文件,重启后生效(服务码头工人重启)。
DOCKER_OPTS=? h=unix:///var/运行/docker.sock - h=0.0.0.0:2375"
<强>,CentOS 7 强>
打开/usr/lib/systemd/系统/码头工人。服务文件,修改ExecStart这行。
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/运行/码头工人。袜子
重启后生效
systemctl daemon-reload , systemctl restart 码头工人。服务
测试是否生效
curl http://127.0.0.1:2375信息
<强>新建Maven工程强>
砰的一声。xml配置如下:
& lt; project xmlns=癶ttp://maven.apache.org/POM/4.0.0", xmlns: xsi=癶ttp://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</modelVersion> & lt;才能groupId> test.springboot.docker</groupId> & lt;才能artifactId> docker-springboot</artifactId> & lt;才能version> 0.0.1-SNAPSHOT</version> & lt;才能parent> ,,,& lt; groupId> org.springframework.boot ,,,& lt; artifactId> spring-boot-starter-parent ,,,& lt; version> 1.5.3.RELEASE & lt;才能/parent> & lt;才能properties> ,,,& lt; java.version> 1.8 & lt;/java.version> & lt;才能/properties> & 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;才能/dependencies> & 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> 0.4.14 ,,,,,,,& lt; configuration> ,,,,,,,,,& lt; imageName> $ {docker.image.prefix}/{project.artifactId} & lt;美元/imageName> ,,,,,,,,,& lt; dockerDirectory> src/主/docker ,,,,,,,,,& lt; dockerHost> http://192.168.1.200:2375 ,,,,,,,,,& 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;/plugins> & lt;才能/build> & lt;/project>
imageName:指定了镜像的名字
dockerDirectory:指定Dockerfile的位置
dockerHost:指定码头工人远程API地址
资源:指那些需要和Dockerfile放在一起,在构建镜像时使用的文件,一般应用jar包需要纳入
创建Java类
package 你好; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; null null null null null null null null null null null null null null null null null null null null null null如何对弹簧引导与码头工人进行部署