Docker容器化部署Python应用执行docker build命令生成docker容器报错:Smporary failure in name resolution
程序员文章站
2022-06-09 18:15:00
Docker容器化部署Python应用执行docker build命令生成docker容器报错问题简述报错信息问题原因解决方式问题简述因项目需求python项目需要使用Docker容器化部署,Dockerfile文件已编辑完成内容如下报错信息WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionEr...
问题简述
因项目需求python项目需要使用Docker容器化部署,Dockerfile文件编辑内容如下:
FROM python:3.6.10
RUN mkdir /usr/src/myapp -p
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN pip3 install -r requirements.txt
WORKDIR /usr/src/myapp/ETLProject
CMD python manage.py runserver 0:8888
执行docker build命令时到pip3 install -r requirements.txt发生报错
报错信息
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSmporary failure in name resolution',)': /simple/some-package/
问题原因
Docker未使用正确的DNS设定造成解析错误
解决方式
指定Docker使用的DNS
- 打开/etc/default/docker
vim /etc/default/docker
- 更改 DNS 設定
DOCKER_OPTS="--dns 8.8.8.8"
- 重启docker
systemctl restart docker
4.再次执行docker build命令成功生成容器ID如下:
本文地址:https://blog.csdn.net/file_data/article/details/107624626