Hi to make my question clear, I will use sever pictures here. First, I want to install rstudio server in my new docker image, the rpm file I downloaded beforehand,using
wget https://download2.rstudio.org/server/centos6/x86_64/rstudio-server-rhel-1.3.959-x86_64.rpm
here is my Dockerfile:
With Dockerfile and rserver rpm in current folder I want to build the image using :
docker build -t temp:temp .
However,sometimes the setup process is terminated due to unable to connect to the mirror site at the step yum install, sometimes it succeeded with some sites weird:
This success process mentions a mirror site:mirrors.163.com, however I never set mirror site as this, actually I didn't even know this site.
I checked my settings in three places:
1 my host machine's /etc/yum.repos.d/CentOS-Base.repo:

2 The container run according to that build up image's /etc/yum.repos.d/CentOS-Base.repo:
3 I also checked my docker's /etc/docker/daemon.json:
So here is my question: 1 why the build image process sometimes failed and sometimes succeed? 2 why the building process used a mirror site I have never seen and never set before? Or it was set to some place I haven't been awared of?
Another background info is that since the host machine is in china,due to policy it can't freely access the website outside freely, that's why the mirror setting is so critical, sometimes it takes us several hours to figure out the correct mirror site setting.
3 So the last question is, is there a way to quickly setup the mirror set inside a country in order for the docker to run installation freely?
My host machine and docker image are all centos 7.4




If you want to lock down the mirror being used to download packages then you need to modify
/etc/yum.repos.d/CentOS-Base.repoon the image.Create a local
CentOS-Base.repothat specifies a working mirror. For example, http://mirror.centos.org/ (but you need to choose one that works reliably for you).CentOS-Base.repoDockerfileIn the
Dockerfileyou copy that configuration across into the correct location and it will then be used by subsequentyumcommands. You also explicitly disabled thefastestmirrorplugin.FYI I have replaced the
.rpmfile that you are using by one that's directly downloaded during the Docker build. However, you can replace this with your original approach where youCOPYacross an.rpm. Personally I prefer to have the whole thing wrapped up in theDockerfile.