CentOS7 下 配置Docker远程访问 与 windows下使用maven构筑Spring Boot 的 Docker镜像到远程服务端
1、设置Docker服务端,以支持远程访问:
修改docker服务端配置文件,命令:
vim /usr/lib/systemd/system/docker.service
修改后:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target [Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd and above support this version.
#TasksMax=infinity
TimeoutStartSec=
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=
StartLimitInterval=60s
#remote call define
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock [Install]
WantedBy=multi-user.target
以上加粗的蓝色内容即是新增配置,注意我使用的Docker版本为
Docker version 17.09.0-ce, build afdb6d4
不同的版本可能配置文件内容不一样。
刷新配置、重启docker,命令:
systemctl daemon-reload
systemctl restart docker
查看修改结果命令:
ps -ef|grep docker 可看到:
......
root : ? :: /usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
......
2、普通Linux下的Docker客户端通过指定服务端IP和端口的方式,可以远程访问Docker服务端,命令格式如下:
docker -H tcp://xxx.xxx.xxx.xxx:2375 images
如此可看到服务端的镜像列表
3、在Windows 中 利用 Maven 为该Docker服务端构筑docker 镜像(该Windows中无须安装Docker):
pom.xml配置插件:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin> <plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>liuyx/test:0.1</imageName>
<!-- 本以为在此设置 前文服务端的地址和端口 可以生效,但是始终会报一个tcp protocol is not supported,鄙人才疏学浅,终究不知为什么,我们还是在别的地方设置吧 -->
<!--<dockerHost>tcp://xxx.xxx.xxx.xxx:2375</dockerHost>-->
<!-- 设置Dockerfile路径,设置了就会忽略baseImage和entryPoint等Dockerfile中应出现的东西,转而去执行Dockerfile-->
<!--<dockerDirectory>src/main/docker</dockerDirectory>-->
<skipDockerBuild>false</skipDockerBuild>
<baseImage>java8</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_HOST”为前文提到的docker服务端的ip和端口,当然也可以直接去系统环境变量设置
set DOCKER_HOST=tcp://xxx.xxx.xxx.xxx:2375
mvn clean package -X docker:build
构筑完毕后,可在服务端查看构筑结果。
(完毕)
CentOS7 下 配置Docker远程访问 与 windows下使用maven构筑Spring Boot 的 Docker镜像到远程服务端的更多相关文章
- Linux RabbitMQ的安装、环境配置、远程访问 , Windows 下安装的RabbitMQ远程访问
Linux RabbitMQ的安装和环境配置 1.安装 RabbitMQ是使用Erlang语言编写的,所以安装RabbitMQ之前,先要安装Erlang环境 #对原来的yum官方源做个备份 1.mv ...
- maven 打包 spring boot 生成docker 镜像
1.所使用材料 ,spring boot 项目 基于maven ,maven 工具, docker工具 ps:为啥使用 docker 公司微服务需要启动太多,有两个优点吧! 1.方便管理,2.减少服务 ...
- CentOS和Windows下配置MySQL远程访问的教程
CentOS和Windows下配置MySQL远程访问的教程 一.前言 由于实验在云服务器上跑的结果不是很理想.所以,现在切换到局域网服务器.因此,需要重新配置 Windows 服务器和 CentO ...
- Myeclipse下使用Maven搭建spring boot项目
开发环境:Myeclipse2017.JDK1.6.Tomcat 8.0.Myeclipse下使用Maven搭建spring boot项目,详细过程如下: 1. New -> Project.. ...
- Spring Boot 和 Docker 实现微服务部署
Spring boot 开发轻巧的微服务提供了便利,Docker 的发展又极大的方便了微服务的部署.这篇文章介绍一下如果借助 maven 来快速的生成微服务的镜像以及快速启动服务. 其实将 Sprin ...
- Spring Boot with Docker
翻译自:https://spring.io/guides/gs/spring-boot-docker/ Spring Boot with Docker 这篇教程带你一步步构建一个Docker镜像用来运 ...
- 集成spring boot + mysql + docker实战
前言 网上找过很多文章,关于通过docker构建mysql容器并将应用容器和docker容器关联起来的文章不多.本文将给出具体的范例.此处为项目的源码 前置条件 该教程要求在宿主机上配置了: dock ...
- 使用Spring Boot创建docker image
目录 简介 传统做法和它的缺点 使用Buildpacks Layered Jars 自定义Layer 简介 在很久很久以前,我们是怎么创建Spring Boot的docker image呢?最最通用的 ...
- Spring Boot 创建 Docker 镜像
随着越来越多的组织转向容器和虚拟服务器,Docker正成为软件开发工作流程中一个更重要的部分.为此,Spring Boot 2.3中最新的功能之中,提供了为Spring Boot应用程序创建 Dock ...
随机推荐
- [转]Apache 配置虚拟主机三种方式
转自: http://www.cnblogs.com/hi-bazinga/archive/2012/04/23/2466605.html 一.基于IP 1. 假设服务器有个IP地址为192.168. ...
- ss简单使用
ss简单使用 ss即socket state. 1.常用语句 ss -l 显示所有处于监听的网络接口连接 ss -pl 显示所有处于监听的网络接口连接,及相应的进程名称.进号等 ss -t -a 显示 ...
- gamma函数及相关其分布
神奇的gamma函数(上) 神奇的gamma函数(下) gamma函数的定义及重要性质 \[\Gamma(x)=\int_0^{\infty}t^{x-1}e^{-t}dt\] \[\Gamma(x+ ...
- C++ 模板学习 函数模板、类模板、迭代器模板
使用模板能够极大到使得代码可重用. 记录一下,方便后续使用. 1. 函数模板,支持多种类型参数 #include <stdio.h> #include <math.h> //函 ...
- 在Cygwin里,如何进入到C盘?
答: cd /cygdrive/c 来源: How to navigate to a directory in C:\ with Cygwin? https://stackoverflow.com/q ...
- Java通信过程的中文乱码的解决
J在基于Java的编程中,常常会碰到汉字的处里及显示的问题.比方一大堆乱码或问号. 这是由于JAVA中默认的编码方式是UNICODE.而中国人通常使用的文件和DB都是基于GB2312或者BIG5等编码 ...
- (转)C#垃圾回收机制详解
GC的前世与今生 虽然本文是以.net作为目标来讲述GC,但是GC的概念并非才诞生不久.早在1958年,由鼎鼎大名的图林奖得主John McCarthy所实现的Lisp语言就已经提供了GC的功能,这是 ...
- 使用 mongodb 的 Docker Image 快速上手系列 lab
Docker 主要的概念 Dockerfile => 用來產生 docker image 用的(介紹) Image => 可以用來產生 docker container Container ...
- Express application generator的使用
首先拷贝express官网的一篇文章: (http://expressjs.com/en/starter/generator.html ) Express application generator ...
- Dijkstra和Floyd_warshall
import java.util.Arrays; import java.util.Scanner; /*题目描写叙述: 有n个城市.城市间有m条道路.每条道路都有长度d.给你起点城市s终点终点t.要 ...