curl: (56) Recv failure: Connection reset by peer

Docker redirection problem: curl: (56) Recv failure: Connection reset by peer


Solutions

☺ The following considerations are for docker deployment of springboot projects. I set the port to 8848 in the springboot configuration file application.properties.


1. 考虑是不是端口冲突了For example, the port of the currently running project is 8848, but an old project is already running before the project is run, and the port of the old project is also 8848.

# 查看端口占用情况
netstat -lntp | grep 8848

2. 考虑项目端口是否忘记暴露了, the premise is that the project is built using dockerfile, if dockerCompose, please see the third point

■ The specific situation is as follows: you can see that the port location is empty

  • dockerfile contents:


Solution 1: Add the EXPOSE port number to the dockerfile file, and select port mapping -p port number when creating and starting the container: container port (expose 8848)

Add the EXPOSE port number exposure method, which can only be exposed to other containers, but not to the host, that is, curl localhost: The port number is inaccessible, and port mapping needs to be done -p host port: port exposed by dockerfile , and then can be accessed on the host machine


3. 考虑项目是否存在多种环境的配置文件[application.yml 或 application.properties]For example, if you have both a development environment [application.properties] and a production environment configuration file [application-prod.properties], and your intention is that the configuration file run by docker is for the production environment, you need to select it before packaging. Good build environment configuration files

☺ Add the function of the command line -U clean package: to make the packaging more complete and avoid the packaged jar package from being downloaded completely from the remote warehouse, causing the error of was cached in the local repository. Add the command line -U clean package


4. Consider using -p for port mapping, and check whether the port number is filled in normally during the test:


5. Test in the browser and consider whether the server's security group or firewall is allowed:



If this article is helpful to you, please remember to give Yile a like, thank you!

Guess you like

Origin blog.csdn.net/weixin_45630258/article/details/125507193