环境
ubuntu18.04
dokcer
由于项目经常需要部署,所以docker 使用的较多,但是从dockerhub上拉取得镜像很多都有一个毛病就是没有安装vim,好点的直接通过下面着两条命令解决
apt-get update
apt-get install vim
但是大多数都不能解决,因为这个问题的本质是apt的安装源不行,再简单点说就是ubuntu的镜像源不是国内的镜像源,所以需要更换国内的镜像源,注意注意注意:先查看自己的ubutu版本,然后再去下载对应版本的镜像源,否则没用。如下贴出几个国内的镜像源网址
清华源网址:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
阿里源网址:https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11oCR0Cw
还有网易源,中科大源等注意版本。
还源也很简单
位置在 cd /etc/apt/sources.list里面。建议先备份一份
然后将找到的镜像源复制到sources.list里面保存
最后别忘先更新
apt-get update 然后再安装东西。
然而,然而,然而,事情哪能一帆风顺,走到这里其实还可能会报错例如我的
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
Couldn't create temporary file /tmp/apt.conf.gYFOaS for passing config to apt-key
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:1 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 InRelease [1581 B]
Err:1 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 InRelease
Couldn't create temporary file /tmp/apt.conf.kx59aZ for passing config to apt-key
Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Err:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Couldn't create temporary file /tmp/apt.conf.sP6254 for passing config to apt-key
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Err:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Couldn't create temporary file /tmp/apt.conf.TUoUS6 for passing config to apt-key
Err:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Couldn't create temporary file /tmp/apt.conf.lDoKKb for passing config to apt-key
Fetched 338 kB in 5s (64.9 kB/s)
Reading package lists... Done
于是我又是一番探索,无计可施,终于想起来我有个毛病,遇到报错先百度,报错内容都不看,其实只要好好看看报错内容就能定位90%的问题,这写的还要多清楚,不能在/tmp创建文件,
赋权就行了
chmod 777 /tmp
以此为鉴,下不为例,一定一定要看报错内容。