Docker 内pip安装package报错: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'
说来奇幻(对本菜来说, 经常遇到堪称奇幻的问题)
之前在docker里面各种安装都没问题, 也不知道什么引起的, 昨天晚上调试的时候卸载了一个包的版本,然后就安不上了.
宿主机安装依然各种流畅,唯独docker容器不行.
网上找了许多方法, 最后在 /etc/resolv.conf 文件内添加如下的代码解决了:
nameserver 8.8.8.8
https://blog.csdn.net/qq_17351077/article/details/77498173
上面的博客提到了这个方法,但是不明白什么原因, 所以就没试, 然后在
上又找到了同样的方案,这次这哥们给了点说明: Docker没有使用正确的DNS服务器。将谷歌的DNS服务器地址 添加到那个配置文件
Your problem comes from the fact that Docker is not using the proper DNS server. You can fix it in three different ways :
1. Adding Google DNS to your local config
Modifying /etc/resolv.conf and adding the following lines at the end
# Google IPv4 nameservers nameserver 8.8.8.8 nameserver 8.8.4.4
If you want to add other DNS servers, have a look here.
However this change won't be permanent (see this thread). To make it permanent : $ sudo nano /etc/dhcp/dhclient.conf Uncomment and edit the line with prepend domain-name-server : prepend domain-name-servers 8.8.8.8, 8.8.4.4;
Restart dhclient : $ sudo dhclient.
2. Modifying Docker config
Systems that run Ubuntu or an Ubuntu derivative on the desktop typically use 127.0.0.1 as the default nameserver in /etc/resolv.conf file.
To specify a DNS server for use by Docker :
1. Log into Ubuntu as a user with sudo privileges.
2. Open the /etc/default/docker file for editing :
$ sudo nano /etc/default/docker
3. Add the following setting for Docker.
DOCKER_OPTS="--dns 8.8.8.8"
4. Save and close the file.
5. Restart the Docker daemon :
$ sudo systemctl restart docker
3. Using a parameter when you run Docker
When you run docker, simply add the following parameter : --dns 8.8.8.8
我是用的第一个方法, 虽然解决了, 但是为什么之前都没出现这个问题呢?
我服务器默认的是阿里云的DNS服务器地址, 查看了下我的电脑虚拟机的,用的是虚拟的局域网IP地址,
docker会继承宿主机的DNS服务器地址,难不成是阿里云的DNS服务器的问题?但是我宿主机没事
Docker 内pip安装package报错: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'的更多相关文章
- 启动hadoop时候报错:localhost: ssh: Could not resolve hostname localhost: Temporary failure in name resolution”
这个错误是由于配置文件没有配置好.解决方案如下: 1 打开profile文件 vim /etc/profile 2 在文件最后加入的内容应该如下(高亮的两句一般是大家缺少的): export JAVA ...
- pycharm安装 package报错:module 'pip' has no attribute 'main'
转自: <pycharm安装 package报错:module 'pip' has no attribute 'main'> https://www.cnblogs.com/Fordest ...
- Pycharm安装package报错:AttributeError: module 'pip' has no attribute 'main'
Pycharm安装package报错:AttributeError: module 'pip' has no attribute 'main' 确认pip已经升级到目前最新版本了. 在网上搜寻后,解决 ...
- pip安装pycrypto报错:Microsoft Visual C++ 14.0 is required. 和 SSLError: HTTPSConnectionPool的解决办法
今天本打算把[Python3爬虫]网易云音乐爬虫 的代码敲一遍, 但是在安装pycrypto老是报错, 由于我计算是win10, 并且也有vs2017 python3环境下安装pycrypto的一些问 ...
- windows安装anaconda 报错failed to create anacoda menu ?
windows安装anaconda 报错failed to create anacoda menu ? 装了无数次,每次都是 failed to create anacoda menu然后无选择忽略, ...
- pip安装软件报错 utf-8 code can't decode byte 0xcf in position7
pip安装软件报错 utf-8 code can't decode byte 0xcf in position7 根据错误提示的路径找到__init__.py文件 根据错误提示的最后几句话找到对应的行 ...
- python pip安装模块报错 "Can't connect to HTTPS URL because the SSL module is not available."
在升级python版本为3.6之后,pip安装模块报错. 报错信息如图: 原因是系统自带的openssl版本与python3的版本不匹配,所以这里只要升级openssl版本就可以解决问题. yum - ...
- pip安装setuptools_rust报错
公司项目中有主备CDN存在,由于阿里云以及腾讯云的预热功能不支持自动(一般是云函数),所以就根据云厂商给的脚本稍作更改,手动传入数据来进行预热. 由于之前部署在centos7.7系统python2.7 ...
- 解决vue安装less报错Failed to compile with 1 errors的问题
1.创建vue项目后安装less,执行 npm install less less-loader --save-dev 下载版本为:less-loader@6.1.0 , less@3.11.3,重启 ...
随机推荐
- MVC的一个简单实例
基本思路: 一个Regist.jsp注册页面,用于收集用户信息,发送请求给控制器Servlet:控制器层Servlet封装模型层对象 jBean,并调用其方法regiser实现用户信息的保存:模型层J ...
- element 库 date-picker 的 disabledDate 的坑
概述 今天使用 element 库的 date-picker 组件,使用日期范围,然后使用了 disabledDate 属性,把 2018 年 1 月和 2020 年 12 月之后的日期全部 disa ...
- docker原理(转)
转自:https://zhuanlan.zhihu.com/p/22382728 https://zhuanlan.zhihu.com/p/22403015 在学习docker的过程中,我发现目前do ...
- JavaSE部分1.Java基础
1.为什么重写equals()还要重写hashcode()? (equals()和hashCode()是java Object中两个基本方法) 首先equals与hashcode间的关系是这样的: ...
- C# 获取当前网页HTML
//引用COM组件 //Microsoft HTML Object Library //Microsoft Internet Controls SHDocVw.ShellWindows shellWi ...
- kafka学习(六)
用kafka构建数据管道 把kafka看着是一个数据的端点,怎么把kafka数据移到mysql,elasticSearchs 这里面介绍kafka connect API怎么样帮忙我们把数据移到我 ...
- IntelliJ IDEA 快捷键终极大全
自动代码 常用的有fori/sout/psvm+Tab即可生成循环.System.out.main方法等boilerplate样板代码 . 例如要输入for(User user : users)只需输 ...
- MySQL插入emoji表情报错 SQLException: Incorrect string value 的两种解决方案
摘抄自:https://blog.csdn.net/dmw412724/article/details/81119325 原因:mysql的UTF-8只支持三个字节的存储,而一般字符是三个字节,但是e ...
- so easy(并查集+unordered_map)
There are nn points in an array with index from 11 to nn, and there are two operations to those poin ...
- Scrapy 教程(三)-网站解析
有经验的人都知道,解析网站需要尝试,看看得到的数据是不是想要的,那么在scrapy中怎么尝试呢? 调试工具-shell 主要用于编写解析器 命令行进入shell scrapy shell url 这个 ...