说来奇幻(对本菜来说, 经常遇到堪称奇幻的问题)

之前在docker里面各种安装都没问题, 也不知道什么引起的, 昨天晚上调试的时候卸载了一个包的版本,然后就安不上了.

宿主机安装依然各种流畅,唯独docker容器不行.

网上找了许多方法, 最后在 /etc/resolv.conf 文件内添加如下的代码解决了:

nameserver 8.8.8.8

https://blog.csdn.net/qq_17351077/article/details/77498173

上面的博客提到了这个方法,但是不明白什么原因, 所以就没试, 然后在

https://stackoverflow.com/questions/28668180/cant-install-pip-packages-inside-a-docker-container-with-ubuntu/41989423

上又找到了同样的方案,这次这哥们给了点说明:  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

As explained in the docs :

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'的更多相关文章

  1. 启动hadoop时候报错:localhost: ssh: Could not resolve hostname localhost: Temporary failure in name resolution”

    这个错误是由于配置文件没有配置好.解决方案如下: 1 打开profile文件 vim /etc/profile 2 在文件最后加入的内容应该如下(高亮的两句一般是大家缺少的): export JAVA ...

  2. pycharm安装 package报错:module 'pip' has no attribute 'main'

    转自: <pycharm安装 package报错:module 'pip' has no attribute 'main'> https://www.cnblogs.com/Fordest ...

  3. Pycharm安装package报错:AttributeError: module 'pip' has no attribute 'main'

    Pycharm安装package报错:AttributeError: module 'pip' has no attribute 'main' 确认pip已经升级到目前最新版本了. 在网上搜寻后,解决 ...

  4. pip安装pycrypto报错:Microsoft Visual C++ 14.0 is required. 和 SSLError: HTTPSConnectionPool的解决办法

    今天本打算把[Python3爬虫]网易云音乐爬虫 的代码敲一遍, 但是在安装pycrypto老是报错, 由于我计算是win10, 并且也有vs2017 python3环境下安装pycrypto的一些问 ...

  5. windows安装anaconda 报错failed to create anacoda menu ?

    windows安装anaconda 报错failed to create anacoda menu ? 装了无数次,每次都是 failed to create anacoda menu然后无选择忽略, ...

  6. pip安装软件报错 utf-8 code can't decode byte 0xcf in position7

    pip安装软件报错 utf-8 code can't decode byte 0xcf in position7 根据错误提示的路径找到__init__.py文件 根据错误提示的最后几句话找到对应的行 ...

  7. python pip安装模块报错 "Can't connect to HTTPS URL because the SSL module is not available."

    在升级python版本为3.6之后,pip安装模块报错. 报错信息如图: 原因是系统自带的openssl版本与python3的版本不匹配,所以这里只要升级openssl版本就可以解决问题. yum - ...

  8. pip安装setuptools_rust报错

    公司项目中有主备CDN存在,由于阿里云以及腾讯云的预热功能不支持自动(一般是云函数),所以就根据云厂商给的脚本稍作更改,手动传入数据来进行预热. 由于之前部署在centos7.7系统python2.7 ...

  9. 解决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,重启 ...

随机推荐

  1. webpack安装大于4.x版本(没有配置webpack.config.js)

    webpack安装大于4.x版本(没有配置webpack.config.js) webpack 输出参数-o 高版本  如果安装的webpack版本大于4+,还需要安装webpack-cli.在没有配 ...

  2. 64位ubuntu下安装ia32-libs

    echo "deb http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse" &g ...

  3. 在aspx页面的checkbox取值验证

    在做项目的时候遇到了一个选择性的问题,之前都可以用$("#id").checked,但是不知道为什么现在不可以了,只能if($(this).is(":checked&qu ...

  4. 前端必须掌握的 nginx 技能(1)

    概述 作为一个前端,我觉得必须要学会使用 nginx 干下面几件事: 代理静态资源 设置反向代理(添加https) 设置缓存 设置 log 部署 smtp 服务 设置 redis 缓存(选) 下面我按 ...

  5. Flink整体执行流程

    以Flink源码中自带的WordCount为例,执行的入口从用户程序的execute()函数入手,execute()的源码如下: public JobExecutionResult execute(S ...

  6. C# 获取当前网页HTML

    //引用COM组件 //Microsoft HTML Object Library //Microsoft Internet Controls SHDocVw.ShellWindows shellWi ...

  7. RequestContextHolder

    JShop简介:jshop是一套使用Java语言开发的B2C网店系统,致力于为个人和中小企业提供免费.好用的网店系统. 项目主页:http://git.oschina.net/dinguangx/js ...

  8. 应用安全 - CMS - PHPCMS漏洞汇总

    CVE-2011-0644 Date: 2011.1 类型: /flash_upload.php SQL注入 影响版本:phpCMS 2008 V2 PHPCMS PHPCMS通杀XSS 在我要报错功 ...

  9. 【Linux开发】Linux动态链接库搜索路径问题

    说明:下列内容是从网上获取的,未经验证,仅作参考之用 动态库的搜索路径搜索的先后顺序是: (1).编译目标代码时指定的动态库搜索路径:(2).环境变量LD_LIBRARY_PATH指定的动态库搜索路径 ...

  10. 【Linux命令】解压相关命令

    xxx.tar.gz   :   tar xvzf xxx.tar.gz xxx.tar.bz2 :   tar -vxjf   xxx.tar.bz2