我只想尝试在centos:latest映像中安装sshd。
我尝试安装“ passwd”,键入如下命令:
yum install passwd
但是我有这样的错误:
Failed to set locale, defaulting to C.UTF-8
CentOS-8 - AppStream 0.0 B/s | 0 B 00:30
Errors during downloading metadata for repository 'AppStream':
- Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]
我不知道为什么不能在docker容器中使用yum进行安装?
答案 0 :(得分:0)
只需在我的本地计算机上对此进行测试:
docker run -it -d --name test centos:latest;
docker exec -it test /bin/bash;
在docker容器中:
[root@f3b8b3fe70df /]# yum update -y;
[root@f3b8b3fe70df /]# yum install passwd;
答案 1 :(得分:0)
使用--network host
docker run --network host -it -d --name test centos:latest
答案 2 :(得分:0)
伪装允许 docker 入口和出口:
firewall-cmd --zone=public --add-masquerade --permanent
特别允许端口 80/443 上的传入流量:
firewall-cmd --zone=public --add-port=443/tcp
重新加载防火墙以应用永久规则:
firewall-cmd --reload
重启泊坞窗:
systemctl restart docker