: Failed to establish a new connection: [Errno -2] Name or service not known'"" type="hidden"/>

jenkins構建報錯"' : Failed to establish a new connection: [Errno -2] Name or service not known'"


  • 問題現象
    jenkins容器內發起接口請求報錯:

  • 分析
    報主機無法獲取,在Jenkins容器內ping主機域名(如未安裝ping,先安裝ping工具),ping不通說明網絡連接配置有誤

  • 解決
    jenkins容器內/etc/hosts新增一行配置,格式為:主機ip地址 域名
    如需要對testerhome.com發起請求,先用ping命令確定ip,然后編輯入hosts文件內

  • 注意點
    每次重啟容器后,hosts文件會初始化,導致之前新增的配置失效。可以在重啟后繼續添加
    docker exec -it -u root 647bf755ba2e /bin/bash -c "echo -e $主機ip $域名1 $域名2 >> /etc/hosts"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM