由於沒有配置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] ----------------------------------------------