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

网友投稿 272 2022-10-22

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

​1、设置Docker服务端,以支持远程访问:​修改docker服务端配置文件,命令:vim /usr/lib/systemd/system/docker.service修改后:[Unit]Description=Docker Application Container EngineDocumentation=firewalld.serviceWants=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 dockerExecStart=/usr/bin/dockerdExecReload=/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=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process# restart the docker process if it exits prematurelyRestart=on-failureStartLimitBurst=3StartLimitInterval=60s#remote call defineExecStart=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-reloadsystemctl restart docker查看修改结果命令:ps -ef|grep docker可看到:......root 29124 1 0 03:53 ? 00:00:11 /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配置插件: org.springframework.boot spring-boot-maven-plugin true com.spotify docker-maven-plugin 0.4.13 liuyx/test:0.1             false java8 ["java","-jar","/${project.build.finalName}.jar"] / ${project.build.directory} ${project.build.finalName}.jar 构筑命令:#在此,先设置当前的环境变量“DOCKER_HOST”为前文提到的docker服务端的ip和端口,当然也可以直接去系统环境变量设置set DOCKER_HOST=tcp://xxx.xxx.xxx.xxx:2375mvn clean package -X docker:build构筑完毕后,可在服务端查看构筑结果。(完毕)​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:电信基站(电信基站安装在我楼顶合法吗)
下一篇:比价(比价网)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~