简体   繁体   English

HttpHostConnectException:连接到 localhost:2375 [localhost/127.0.0.1] 失败:连接被拒绝

[英]HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1] failed: Connection refused

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default) on project Bookstore: 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] failed: Connection refused [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default) on project Bookstore: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded. javax.ws.rs.ProcessingException:org.apache.http.conn.HttpHostConnectException:连接到 localhost:2375 [localhost/127.0.0.1] 失败:连接被拒绝

Why is this Exception Keep Occurring and how can i resolve it, i am building docker image from war file.为什么这个异常不断发生,我该如何解决它,我正在从 war 文件构建 docker 图像。

pom.xml pom.xml

<modelVersion>4.0.0</modelVersion>
<groupId>net.codejava.javaee.bookstore</groupId>
<artifactId>Bookstore</artifactId>
<version>1.2.1</version>
<packaging>war</packaging>

 <properties>
 <docker.image.prefix>alesblaze</docker.image.prefix>
 </properties>

 <dependencies>
     <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>javax.servlet-api</artifactId>
         <version>3.1.0</version>
         <scope>provided</scope>
     </dependency>
     <dependency>
         <groupId>javax.servlet.jsp</groupId>
         <artifactId>javax.servlet.jsp-api</artifactId>
         <version>2.3.1</version>
         <scope>provided</scope>
     </dependency>
     <dependency>
         <groupId>jstl</groupId>
         <artifactId>jstl</artifactId>
         <version>1.2</version>
     </dependency>
     <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>5.1.30</version>
     </dependency>
 </dependencies>  

<build>
 <sourceDirectory>src</sourceDirectory>
 <plugins>
   <plugin>
     <artifactId>maven-compiler-plugin</artifactId>
     <version>3.5.1</version>
     <configuration>
       <source>1.8</source>
       <target>1.8</target>
     </configuration>
   </plugin>
   <plugin>
     <artifactId>maven-war-plugin</artifactId>
     <version>2.6</version>
     <configuration>
     <finalName>BookStore</finalName>
       <warSourceDirectory>WebContent</warSourceDirectory>
       <failOnMissingWebXml>false</failOnMissingWebXml>
     </configuration>
   </plugin>

   <plugin>
 <groupId>com.spotify</groupId>
 <artifactId>docker-maven-plugin</artifactId>
 <version>1.0.0</version>
 <configuration>
 <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
 <dockerDirectory>Docker</dockerDirectory>
 <dockerHost>https://localhost:3000</dockerHost>
 <forceTags>true</forceTags>
 <imageTags>
 <imageTag>${project.version}</imageTag>
 <imageTag>latest</imageTag>
 </imageTags>
 <serverId>docker-hub</serverId>
 <registryUrl>https://hub.docker.com/</registryUrl>
 <resources>
 <resource>
 <targetPath>/</targetPath>
 <directory>${project.build.directory}</directory>
 <include>${project.build.finalName}.war</include>
 </resource>
 </resources>
 </configuration>
 <executions>
 <execution>
 <phase>package</phase>
 <goals>
 <goal>build</goal>
 </goals>
 </execution>
 </executions>
</plugin>

 </plugins>
</build>
</project>

DockerFile DockerFile


DockerFile
``` FROM tomcat:8.5-alpine
VOLUEME /volume/mysql/
COPY /target/BookStore.war /usr/local/tomcat/webapps/app.war
RUN sh -c 'touch /usr/local/tomcat/webapps/app.war'
d
ENTRYPOINT ["sh", "-c" , "java -Djava.security.edg=file:/dev/./urandom -jar /usr/local/tomcat/webapps/app.war] ```

UPDATE更新

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default) on project Bookstore: Exception caught: Timeout: GET https://localhost:2375/version: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:2375 [localhost/127.0.0.1] failed: connect timed out 

now i am getting this error after turning off the firewall, what to do?现在关闭防火墙后出现此错误,该怎么办?

  1. set DOCKER_HOST into env variables as tcp://localhost:2375将 DOCKER_HOST 设置为 env 变量为 tcp://localhost:2375

  2. change docker desktop settings, as per the image attached.根据所附图像更改 docker 桌面设置。

  3. restart the docker desktop重启docker桌面

在此处输入图像描述

You should set the DOCKER_HOST environment variable.您应该设置DOCKER_HOST环境变量。 From the docs :文档

By default the plugin will try to connect to docker on localhost:2375.默认情况下,插件将尝试连接到 localhost:2375 上的 docker。 Set the DOCKER_HOST environment variable to connect elsewhere.设置 DOCKER_HOST 环境变量以连接其他地方。

See as well How to define a custom docker host url?另请参阅如何定义自定义 docker 主机 url?

For example on Windows:例如在 Windows 上:

set DOCKER_HOST=tcp://localhost:3000& mvn clean install

The Docker Engine on localhost must be configured to accept incoming connections on port 3000本地主机上的 Docker 引擎必须配置为接受端口 3000 上的传入连接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TestRestTemplate HttpHostConnectException:连接到本地主机:8082 [localhost/127.0.0.1] 失败:连接被拒绝 - TestRestTemplate HttpHostConnectException: Connect to localhost:8082 [localhost/127.0.0.1] failed: Connection refused 无法执行 HTTP 请求:连接到 localhost:8000 [localhost/127.0.0.1] 失败:连接被拒绝(连接被拒绝) - Unable to execute HTTP request: Connect to localhost:8000 [localhost/127.0.0.1] failed: Connection refused (Connection refused) org.apache.http.conn.HttpHostConnectException:连接到127.0.0.1:7055 [/127.0.0.1]失败:连接被拒绝:connect - org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:7055 [/127.0.0.1] failed: Connection refused: connect java.net.ConnectException:无法连接到 localhost/127.0.0.1(端口 80):连接失败:ECONNREFUSED(连接被拒绝) - java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused) 无法连接到服务器:localhost / 127.0.0.1:9000:尝试一次失败。 java.net.ConnectException:连接被拒绝 - Failed to connect to server: localhost/127.0.0.1:9000: try once and fail. java.net.ConnectException: Connection refused org.apache.http.conn.HttpHostConnectException:拒绝连接到http:// localhost - org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused finishConnect(..) 失败:连接被拒绝:localhost/127.0.0.1,错误:Webflux、Webclient、Spring 启动、java - finishConnect(..) failed: Connection refused: localhost/127.0.0.1 , error: Webflux, Webclient, Spring boot, java Appium:连接到127.0.0.1:4723 [/127.0.0.1]失败:连接被拒绝:connect - Appium: Connect to 127.0.0.1:4723 [/127.0.0.1] failed: Connection refused: connect 如何修复“nodetool:无法连接到&#39;localhost:7199&#39; - ConnectException:&#39;连接被拒绝(连接被拒绝)&#39;。” - how to fix “nodetool: Failed to connect to 'localhost:7199' - ConnectException: 'Connection refused (Connection refused)'.” 为什么拒绝连接到localhost? - Why connection to localhost is refused?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM