Docker安装镜像踩坑记


几个安装过程中遇到的坑以及对应的解决方案,一方面作为自己的记录,防止后面遇到重新查看;另一方面,如果能帮助大家解决问题,不胜欢喜。

更新国内docker镜像源方法

安装Docker Ubuntu镜像时将镜像的源更改为网易源的方法

RUN sed -i 's/http:\/\/archive.ubuntu.com\/ubuntu\//http:\/\/mirrors.163.com\/ubuntu\//g' /etc/apt/sources.list

添加阿里云的源

另一个错误是Ubuntu “Failed to fetch”, 原因是DNS解析问题,如果在docker容器里面,可以用如下方案解决

sudo vim /etc/resolv.conf 

在文件末尾添加如下两行

nameserver 223.5.5.5
nameserver 223.6.6.6

保存后运行

sudo apt-get update

即可

在Dockerfile 里面可以进行如下操作

RUN echo 'nameserver 223.5.5.5' /etc/resolv.conf
RUN echo 'nameserver 223.6.6.6' /etc/resolv.conf
RUN apt-get update

上述地址为 阿里云地址

nvidia-smi ubuntu 不可访问

https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/
hash mismatch 或者超时,或者权限不够
在访问该地址https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/ ,并且下载 pub 文件到本地,如

wget  https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub > pub_file

然后在Dockerfile中添加

COPY pub_file .
RUN sudo apt-key add - < pub_file 

添加清华镜像

Dockerfile 中添加

RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

python 安装文件过大,且清华镜像没有

将安装所需 whl 下载到本地,在Dockerfile中添加

COPY torch-1.3.0+cu92-cp36-cp36m-linux_x86_64.whl .
COPY torchvision-0.4.1+cu92-cp36-cp36m-linux_x86_64.whl .
RUN pip3 install torch-1.3.0+cu92-cp36-cp36m-linux_x86_64.whl
RUN pip3 install torchvision-0.4.1+cu92-cp36-cp36m-linux_x86_64.whl

参考文章
[1]: https://askubuntu.com/questions/650032/gpg-errorthe-following-signatures-were-invalid-keyexpired
[2]:https://github.com/NVIDIA/nvidia-docker/issues/571
[3]:https://blog.csdn.net/bitsec/article/details/81537125
[4]: https://blog.csdn.net/liuYinXinAll/article/details/90042947
[5]: https://stackoverflow.com/questions/28002897/wheel-file-installation

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值