背景/問題:
docker的服務/容器缺少vim問題
bash: vim: command not found
在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