背景/问题:
docker的服务/容器缺少vim问题
在docker的mysql服务中安装Vim
1、执行apt-get update
root@6d8d17e320a0:/# apt-get update
问题:文件下载失败
Err:1 http://security.debian.org/debian-security buster/updates InRelease
Temporary failure resolving ‘security.debian.org’
Err:2 http://repo.mysql.com/apt/debian buster InRelease
Temporary failure resolving ‘repo.mysql.com’
Err:3 http://deb.debian.org/debian buster InRelease
Temporary failure resolving ‘deb.debian.org’
Err:4 http://deb.debian.org/debian buster-updates InRelease
Temporary failure resolving ‘deb.debian.org’
Reading package lists… Done
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving ‘deb.debian.org’
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving ‘security.debian.org’
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving ‘deb.debian.org’
W: Failed to fetch http://repo.mysql.com/apt/debian/dists/buster/InRelease Temporary failure resolving ‘repo.mysql.com’
W: Some index files failed to download. They have been ignored, or old ones used instead.
【解决方案】
1、运行以下命令以授予对该文件角色的read权限:resolv.conf
root@6d8d17e320a0:/etc# chmod o+r /etc/resolv.conf
2、重启docker
备注:下面的c_mysql是我的mysql服务的容器名
退出mysql服务
root@6d8d17e320a0:/# exit
exit
重启docker
[root@25zkf mysql]# sudo service docker restart
Redirecting to /bin/systemctl restart docker.service
启动mysql容器
[root@25zkf mysql]# docker start c_mysql
进入mysql服务
[root@25zkf mysql]# docker exec -it c_mysql /bin/bash
2、下载Vim
再次执行:
root@6d8d17e320a0:/# apt-get update
root@6d8d17e320a0:/# apt-get install vim
y
文章参考:
ubuntu - Docker:解决“ deb.debian.org”的临时故障
docker mysql 中文乱码
Docker 问题 | 编辑文件出现 bash: vi: command not found