Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 313|回复: 0

maven构建docker镜像异常

[复制链接]
  • TA的每日心情
    奋斗
    昨天 20:27
  • 签到天数: 791 天

    [LV.10]以坛为家III

    2049

    主题

    2107

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    723006
    发表于 2021-6-13 08:50:39 | 显示全部楼层 |阅读模式

    由于没有配置ip+2375端口,导致每次跑的时候,都是连接本地的,一直会报错

    [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.5:build (server) on project web-service: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1, localhost/fe80:0:0:0:0:0:0:1%1] failed: Connection refused -> [Help 1]

    研究了几个小时,终于解决了。

    客户端:

    加上 -H tcp://0.0.0.0:2375
    [root@topcheer system]# cat docker.service
    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    BindsTo=containerd.service
    After=network-online.target firewalld.service containerd.service
    Wants=network-online.target
    Requires=docker.socket
    
    [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 -H tcp://0.0.0.0:2375  -H fd:// --containerd=/run/containerd/containerd.sock
    ExecReload=/bin/kill -s HUP $MAINPID
    TimeoutSec=0
    RestartSec=2
    Restart=always
    
    # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
    # Both the old, and new location are accepted by systemd 229 and up, so using the old location
    # to make them work for either version of systemd.
    StartLimitBurst=3
    
    # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
    # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
    # this option work for either version of systemd.
    StartLimitInterval=60s
    
    # 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
    
    # Comment TasksMax if your systemd version does not support it.
    # Only systemd 226 and above support this option.
    TasksMax=infinity
    
    # 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
    
    [Install]
    WantedBy=multi-user.target
    [root@topcheer system]# pwd
    /usr/lib/systemd/system
    [root@topcheer system]#

    重启docker,会发现2375起起来了

    [root@topcheer system]# lsof -i:2375
    COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    dockerd 21337 root    7u  IPv6 128286      0t0  TCP *:2375 (LISTEN)
    [root@topcheer system]#

    客户端:

    2种选择

    要不配置环境变量:

     

     要不在pom.xml添加

    <dockerHost>http://192.168.180.105:2375</dockerHost>

    测试:

    [INFO] Pushing 192.168.180.105:1180/topcheer/docker:1.0.2
    The push refers to repository [192.168.180.105:1180/topcheer/docker]
    75db466d4814: Preparing 
    82128b555bad: Preparing 
    35c20f26d188: Preparing 
    c3fe59dd9556: Preparing 
    6ed1a81ba5b6: Preparing 
    a3483ce177ce: Preparing 
    ce6c8756685b: Preparing 
    30339f20ced0: Preparing 
    0eb22bfb707d: Preparing 
    a2ae92ffcd29: Preparing 
    
    a3483ce177ce: Waiting 
    
    ce6c8756685b: Waiting 
    
    30339f20ced0: Waiting 
    
    0eb22bfb707d: Waiting 
    
    a2ae92ffcd29: Waiting 
    
    35c20f26d188: Layer already exists 
    
    c3fe59dd9556: Layer already exists 
    
    6ed1a81ba5b6: Layer already exists 
    
    75db466d4814: Layer already exists 
    
    82128b555bad: Layer already exists 
    
    0eb22bfb707d: Layer already exists 
    
    a3483ce177ce: Layer already exists 
    
    a2ae92ffcd29: Layer already exists 
    
    ce6c8756685b: Layer already exists 
    
    30339f20ced0: Layer already exists 
    1.0.2: digest: sha256:65b55efa410146d044fa6feba6d9456f13f601f83a2ef73c91e0b0b7a8efc94c size: 2424
    null: null 
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 40.289 s
    [INFO] Finished at: 2019-11-05T18:43:23+08:00
    [INFO] ----------------------------------------------

     

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-9-14 00:18 , Processed in 0.157149 second(s), 29 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表