完全参考:https://blog.csdn.net/wh15055768834/article/details/90228634
1. Eclipse安装Docker Tools插件
通过菜单项添加新的站点,步骤是:Help > Install New Software… > Add…。注明名字为:Docker Nightly,地址为:https://download.eclipse.org/linuxtools/updates-docker-nightly/。
安装完成截图:
3. 连接远程docker服务器的方法
修改docker的配置文件
[root@centos7 ~]# cat /etc/docker/daemon.json
{"hosts":["tcp://0.0.0.0:2376","unix:///var/run/docker.sock"]}
这样远程可以通过2376端口连接到docker
5. 在pom.xml文件中增加插件配置
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- docker的maven插件,官网:https://github.com/spotify/docker-maven-plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.12</version>
<configuration>
<!-- 注意imageName一定要是符合正则[a-z0-9-_.]的,否则构建不会成功 -->
<!-- 详见:https://github.com/spotify/docker-maven-plugin Invalid repository
name ... only [a-z0-9-_.] are allowed -->
<imageName>docker-demo</imageName>
<baseImage>java</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
执行命令“docker run -p 8080:8080 docker-demo:latest”,使用镜像docker-demo:latest启动docker容器。