docker安装在centos6.5
{project_home}>mvn clean package docker:build -DskipTests 遇到以下异常
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.3:build (default-cli) on project eurekaserver: 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] failed: Connection refused: connect -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
经查有两个地方需要更新
- 升级docker-maven-plugin版本,从0.4.3更新到1.0.0
<plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> ... </plugin>
- docker开启远程API端口,有两种方式,可依据自己的环境选择
a.1) 编辑docker
vim /etc/sysconfig/docker other_args="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock" :wq service docker restart
a.2) 在windows系统环境变量中新建DOCKER_HOST值为tcp://{docker_ip}:2375,将这里的{docker_ip},替换为docker所在的centos服务器IP或主机名(用主机名,需要windows配置hosts)
b.1) 修改docker配置文件
#vi /usr/lib/systemd/system/docker.service 在ExecStart这一行后面加上(这里就写4个0,别改成自己的ip) -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock 改完后效果如下 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock :wq 保存退出, 重新加载配置文件#systemctl daemon-reload , 启动docker #systemctl start docker
参考文档:
https://blog.csdn.net/superdangbo/article/details/78558917
https://blog.csdn.net/lvyuan1234/article/details/69255944
https://www.oschina.net/question/2520876_2218738