Docker Community Forums

Share and learn in the Docker community.

How to fix: yum install with error in docker container?

I just would like to try to install sshd in centos:latest image.

I try to install ‘passwd’, typing the command like this:

yum install passwd

But I have a error like this:

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]

I don’t know what wrong in installing using yum in docker container?

Just tested this on my local machine:

docker run -it -d --name test centos:latest;

docker exec -it test /bin/bash;
In docker container:

[root@f3b8b3fe70df /]# yum update -y;
[root@f3b8b3fe70df /]# yum install passwd;