Tag Archives: “‘: Failed to establish a new connection: [Errno 2] Name or service not known'”

jenkins Build Error: “‘: Failed to establish a new connection: [Errno -2] Name or service not known'”

Problem phenomenon

An error is reported when an interface request is initiated in Jenkins container:

Analysis

Report that the host cannot be obtained. Ping the host domain name in the Jenkins container (if Ping is not installed, install the Ping tool first). If the Ping fails, it indicates that the network connection configuration is wrong

Solution:

A new line of configuration is added to/etc/hosts in Jenkins container. The format is: host IP address domain name

If necessary, check testerhome Com initiates a request, first use the ping command to determine the IP, and then edit it into the hosts file

Precautions

After restarting the container each time, the hosts file will be initialized, resulting in the invalidation of the previously added configuration. You can continue to add
after restarting

docker exec -it -u root 647bf755ba2e /bin/bash -c "echo -e $loccalhost_ip $domain1 $domain2 >> /etc/hosts"