1、设置Docker服务端,以支持远程访问:

修改docker服务端配置文件,命令:

  1. vim /usr/lib/systemd/system/docker.service

修改后:

  1. [Unit]
  2. Description=Docker Application Container Engine
  3. Documentation=https://docs.docker.com
  4. After=network-online.target firewalld.service
  5. Wants=network-online.target
  6.  
  7. [Service]
  8. Type=notify
  9. # the default is not to use systemd for cgroups because the delegate issues still
  10. # exists and systemd currently does not support the cgroup feature set required
  11. # for containers run by docker
  12. ExecStart=/usr/bin/dockerd
  13. ExecReload=/bin/kill -s HUP $MAINPID
  14. # Having non-zero Limit*s causes performance problems due to accounting overhead
  15. # in the kernel. We recommend using cgroups to do container-local accounting.
  16. LimitNOFILE=infinity
  17. LimitNPROC=infinity
  18. LimitCORE=infinity
  19. # Uncomment TasksMax if your systemd version supports it.
  20. # Only systemd and above support this version.
  21. #TasksMax=infinity
  22. TimeoutStartSec=
  23. # set delegate yes so that systemd does not reset the cgroups of docker containers
  24. Delegate=yes
  25. # kill only the docker process, not all processes in the cgroup
  26. KillMode=process
  27. # restart the docker process if it exits prematurely
  28. Restart=on-failure
  29. StartLimitBurst=
  30. StartLimitInterval=60s
  31. #remote call define
    ExecStart=
    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
  32.  
  33. [Install]
  34. WantedBy=multi-user.target

以上加粗的蓝色内容即是新增配置,注意我使用的Docker版本为

  Docker version 17.09.0-ce, build afdb6d4

不同的版本可能配置文件内容不一样。

刷新配置、重启docker,命令:

  1. systemctl daemon-reload
  2. systemctl restart docker

查看修改结果命令:

  1. ps -ef|grep docker
  2.  
  3. 可看到:
  4. ......
  5. root : ? :: /usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
  6. ......

2、普通Linux下的Docker客户端通过指定服务端IP和端口的方式,可以远程访问Docker服务端,命令格式如下:

  1. docker -H tcp://xxx.xxx.xxx.xxx:2375 images

如此可看到服务端的镜像列表

3、在Windows 中 利用 Maven 为该Docker服务端构筑docker 镜像(该Windows中无须安装Docker):

pom.xml配置插件:

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot</groupId>
  5. <artifactId>spring-boot-maven-plugin</artifactId>
  6. <configuration>
  7. <executable>true</executable>
  8. </configuration>
  9. </plugin>
  10.  
  11. <plugin>
  12. <groupId>com.spotify</groupId>
  13. <artifactId>docker-maven-plugin</artifactId>
  14. <version>0.4.13</version>
  15. <configuration>
  16. <imageName>liuyx/test:0.1</imageName>
                <!-- 本以为在此设置 前文服务端的地址和端口 可以生效,但是始终会报一个tcp protocol is not supported,鄙人才疏学浅,终究不知为什么,我们还是在别的地方设置吧 -->
  17. <!--<dockerHost>tcp://xxx.xxx.xxx.xxx:2375</dockerHost>-->
  18. <!-- 设置Dockerfile路径,设置了就会忽略baseImage和entryPoint等Dockerfile中应出现的东西,转而去执行Dockerfile-->
  19. <!--<dockerDirectory>src/main/docker</dockerDirectory>-->
  20. <skipDockerBuild>false</skipDockerBuild>
  21. <baseImage>java8</baseImage>
  22. <entryPoint>["java","-jar","/${project.build.finalName}.jar"]</entryPoint>
  23. <resources>
  24. <resource>
  25. <targetPath>/</targetPath>
  26. <directory>${project.build.directory}</directory>
  27. <include>${project.build.finalName}.jar</include>
  28. </resource>
  29. </resources>
  30. </configuration>
  31. </plugin>
  32. </plugins>
  33. </build>

构筑命令:

  1. #在此,先设置当前的环境变量“DOCKER_HOST”为前文提到的docker服务端的ip和端口,当然也可以直接去系统环境变量设置
    set DOCKER_HOST=tcp://xxx.xxx.xxx.xxx:2375
  1. mvn clean package -X docker:build

构筑完毕后,可在服务端查看构筑结果。

(完毕)

CentOS7 下 配置Docker远程访问 与 windows下使用maven构筑Spring Boot 的 Docker镜像到远程服务端的更多相关文章

  1. Linux RabbitMQ的安装、环境配置、远程访问 , Windows 下安装的RabbitMQ远程访问

    Linux  RabbitMQ的安装和环境配置 1.安装 RabbitMQ是使用Erlang语言编写的,所以安装RabbitMQ之前,先要安装Erlang环境 #对原来的yum官方源做个备份 1.mv ...

  2. maven 打包 spring boot 生成docker 镜像

    1.所使用材料 ,spring boot 项目 基于maven ,maven 工具, docker工具 ps:为啥使用 docker 公司微服务需要启动太多,有两个优点吧! 1.方便管理,2.减少服务 ...

  3. CentOS和Windows下配置MySQL远程访问的教程

    CentOS和Windows下配置MySQL远程访问的教程   一.前言 由于实验在云服务器上跑的结果不是很理想.所以,现在切换到局域网服务器.因此,需要重新配置 Windows 服务器和 CentO ...

  4. Myeclipse下使用Maven搭建spring boot项目

    开发环境:Myeclipse2017.JDK1.6.Tomcat 8.0.Myeclipse下使用Maven搭建spring boot项目,详细过程如下: 1. New -> Project.. ...

  5. Spring Boot 和 Docker 实现微服务部署

    Spring boot 开发轻巧的微服务提供了便利,Docker 的发展又极大的方便了微服务的部署.这篇文章介绍一下如果借助 maven 来快速的生成微服务的镜像以及快速启动服务. 其实将 Sprin ...

  6. Spring Boot with Docker

    翻译自:https://spring.io/guides/gs/spring-boot-docker/ Spring Boot with Docker 这篇教程带你一步步构建一个Docker镜像用来运 ...

  7. 集成spring boot + mysql + docker实战

    前言 网上找过很多文章,关于通过docker构建mysql容器并将应用容器和docker容器关联起来的文章不多.本文将给出具体的范例.此处为项目的源码 前置条件 该教程要求在宿主机上配置了: dock ...

  8. 使用Spring Boot创建docker image

    目录 简介 传统做法和它的缺点 使用Buildpacks Layered Jars 自定义Layer 简介 在很久很久以前,我们是怎么创建Spring Boot的docker image呢?最最通用的 ...

  9. Spring Boot 创建 Docker 镜像

    随着越来越多的组织转向容器和虚拟服务器,Docker正成为软件开发工作流程中一个更重要的部分.为此,Spring Boot 2.3中最新的功能之中,提供了为Spring Boot应用程序创建 Dock ...

随机推荐

  1. 使用PHP生成二维码图像

    1.PHP生成二维码图像的类QRcode http://www.phper.org.cn/?post=128 QRcode是用于生成二维条形码的开放源码 (LGPL) 库.提供 API 创建条码图像. ...

  2. Visual Studio提示“无法启动IIS Express Web服务器”的解决方法 vs调试显示无法显示此页面 ,vs调试浏览器白页

    有时,在使用Visual Studio运行ASP.NET项目时,会提示“无法启动IIS Express Web服务器”,无法运行,如图: 这一般出现在重装系统之后,或者项目是从别的电脑上复制过来的.解 ...

  3. 阿里云centos中mysql的安装及一些常识知识

    -------------------------------------------------------------------    阿里云centos中mysql的安装 工具WinSCP v ...

  4. matlib常用知识

    把文件装入矩阵 x = load('ex4x.dat'); y = load('ex4y.dat'); [m, n] = size(x); %得到矩阵x的行数和列数 ex4x.dat共80行,2列,通 ...

  5. 数学图形(1.48)Cranioid curve头颅线

    这是一种形似乎头颅的曲线.这种曲线让我想起读研的时候,搞的医学图像三维可视化.那时的原始数据为脑部CT图像.而三维重建中有一种方式是面绘制,是将每一幅CT的颅骨轮廓提取出来,然后一层层地罗列在一起,生 ...

  6. Maven 入门指南

    为什么要用 Maven? Maven 主要帮助用户完成以下 3 个方面的工作: 生命周期管理,便捷的构建过程: 依赖管理,方便引入所需依赖 Jar 包: 仓库管理,提供统一管理所有 Jar 包的工具: ...

  7. 实战体验几种MySQL Cluster方案(转)

    1.背景 MySQL的cluster方案有很多官方和第三方的选择,选择多就是一种烦恼,因此,我们考虑MySQL数据库满足下三点需求,考察市面上可行的解决方案: 高可用性:主服务器故障后可自动切换到后备 ...

  8. Js组件的一些写法

    首先看下Prototype里的写法: var Class = { create: function() { return function() { this.init.apply(this, argu ...

  9. 移动端 h5开发相关内容总结——CSS篇

    1.移动端开发视窗体的加入 h5端开发以下这段话是必须配置的 <meta name="viewport" content="width=device-width, ...

  10. svn“Previous operation has not finished; run 'cleanup' if it was interrupted“报错的解决方法

    今天碰到了个郁闷的问题,svn执行clean up命令时报错“Previous operation has not finished; run 'cleanup' if it was interrup ...