win10 idea springboot上传镜像到远程docker服务器
1. 开启2375端口,供外部访问docker
vim /usr/lib/systemd/system/docker.service
修改ExecStart为下面一行内容
#ExecStart=/usr/bin/dockerd -H unix://
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
systemctl daemon-reload // 1,加载docker守护线程
systemctl restart docker // 2,重启docker
测试端口是否成功 curl 127.0.0.1:2375/info
在win10客户端添加环境变量

添加dos下mvn命令的执行
直接在Path属性后面添加一条当前Maven的文件地址加上\bin
2. 使用docker-maven-plugin插件上传镜像到docker服务器
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.</version>
<configuration>
<imageName>${project.name}:${project.version}</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<dockerHost>http://192.168.1.10:2375</dockerHost>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
3. 在src/main下面新建文件夹docker
添加文件Dockerfile
FROM daocloud.io/library/java:8u40-b22 #这里是巨坑,下载慢的话一定要关闭从新下载
VOLUME /tmp
ADD gexin-docker-demo-1.0-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
执行命令 mvn clean package docker:build
执行成功出现如下截图内容

报错如下:
1. No plugin found for prefix 'docker' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (F:\repo), nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public)] -> [Help 1]
解决办法:在maven的conf/setting.xml中要加入
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
<pluginGroup>com.spotify</pluginGroup>
</pluginGroups>
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
再次执行mvn clean package docker:build
4. 登录虚拟机可以看到
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gexin-docker-demo 1.0-SNAPSHOT ac7ed71487ca 16 seconds ago 904MB
daocloud.io/library/java 8u40-b22 0a5e1e22983a 4 years ago 815MB
[root@localhost ~]# docker run -d -p 8091:8091 gexin-docker-demo:1.0-SNAPSHOT
bd87d64f71668c9e97eb99de6b8d50ae0a9ca2e80ad0da8081bc50cd000b345c
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bd87d64f7166 gexin-docker-demo:1.0-SNAPSHOT "sh -c 'java $JAVA_O…" 7 seconds ago Up 5 seconds 0.0.0.0:8091->8091/tcp confident_curran
在浏览器查看结果 http://192.168.1.10:8091/
总结:
1. 选择使用docker和dockerfile执行很重要
2. FROM 选择jdk很重要,可能造成下载过慢或者找不到包
win10 idea springboot上传镜像到远程docker服务器的更多相关文章
- IDEA推送docker镜像到私服/利用dockerfile-maven-plugin插件在springboot中上传镜像到远程的docker服务器、远程仓库
利用dockerfile-maven-plugin插件在springboot中上传镜像到远程仓库 这篇文章讲解在开发工具中把打包好的jar编译成docker镜像,上传到远程的docker服务 ...
- 【docker】将Java jar文件生成镜像、上传镜像并生成镜像压缩文件
概述 将Springboot的web服务打包成Jar包后,自动化脚本将jar打包成镜像.上传镜像.并生成镜像的压缩文件: Dockerfile FROM 10.254.9.21/library/ora ...
- docker 私有仓库上传镜像,其他docker服务器从私有镜像下载
<pre name="code" class="cpp">docker:/data# docker ps CONTAINER ID IMAGE CO ...
- C# 上传文件至远程服务器
C# 上传文件至远程服务器(适用于桌面程序及web程序) 2009-12-30 19:21:28| 分类: C#|举报|字号 订阅 最近几天在玩桌面程序,在这里跟大家共享下如何将本地文件上传 ...
- Docker 上传镜像
文章首发自个人网站:https://www.exception.site/docker/docker-push-image 本文中,您将学习如何上传 Docker 镜像至 Docker Hub 上. ...
- springboot上传文件 & 不配置虚拟路径访问服务器图片 & springboot配置日期的格式化方式 & Springboot配置日期转换器
1. Springboot上传文件 springboot的文件上传不用配置拦截器,其上传方法与SpringMVC一样 @RequestMapping("/uploadPicture&q ...
- ASP.NET上传文件到远程服务器(HttpWebRequest)
/// <summary> /// 文件上传至远程服务器 /// </summary> /// <param name="url">远程服务地址 ...
- [Docker]Docker拉取,上传镜像到Harbor仓库
需求 因为项目的需求,需要制作一个基于tomcat的镜像.那么前提就是,需要有tomcat的基础镜像. 怎么做 我的思路跑偏了,本来以为是需要将tomcat下载下来,然后通过docker命令,让它成为 ...
- springBoot上传文件时MultipartFile报空问题解决方法
springBoot上传文件时MultipartFile报空问题解决方法 1.问题描述: 之前用spring MVC,转成spring boot之后发现上传不能用.网上参考说是spring boot已 ...
随机推荐
- GWAS 全基因组关联分析 | summary statistic 概括统计 | meta-analysis 综合分析
有很多概念需要明确区分: 人有23对染色体,其中22对常染色体autosome,另外一对为性染色体sex chromosome,XX为女,XY为男. 染色体区带命名:在标示一特定的带时需要包括4项:① ...
- Spring’s RestTemplate
Spring’s RestTemplate /** * After the word document is generated in memory we can upload it to the s ...
- iptables nat表配置
- 生成model笔记
https://github.com/yscacaca/DeepSense/tree/master/android_test这个才是真正的部署代码,跑这个代码就好. 跑python sample_mo ...
- openresty开发系列28--openresty中操作mysql
openresty开发系列28--openresty中操作mysql Mysql客户端 应用中最常使用的就是数据库了,尤其mysql数据库,那openresty lua如何操作mysql呢? ...
- 【转载】 【Tensorflow】卷积神经网络中strides的参数
原文地址: https://blog.csdn.net/TwT520Ly/article/details/79540251 http://blog.csdn.net/TwT520Ly -------- ...
- wave数据集的回归曲线
wave数据集的回归曲线 import matplotlib.pyplot as pltimport mglearnfrom scipy import sparseimport numpy as np ...
- html中的<pre>标签
定义和用法 pre 元素可定义预格式化的文本.被包围在 pre 元素中的文本通常会保留空格和换行符.而文本也会呈现为等宽字体. <pre> 标签的一个常见应用就是用来表示计算机的源代码. ...
- Spring Cloud Hystrix Dashboard的使用 5.1.3
Hystrix除了可以对不可用的服务进行断路隔离外,还能够对服务进行实时监控.Hystrix可以实时.累加地记录所有关于HystrixCommand的执行信息,包括每秒执行多少.请求成功多少.失败 ...
- elasticsearch in语句和not in语句
sql语句示例: select * from table where t_id in (1,2,3,4) php代码示例: $search_query = [ "bool" =&g ...