CentOS 7 installation error: Cannot find a valid baseurl for repo: base/7/x86_6

If centos in Docker reports an error, restart Docker service, Service Docker Restart,
Detailed reference “docker port mapping or start the container times wrong” https://blog.csdn.net/whatday/article/details/86762264
First, report the wrong situation
When using the yum command, you cannot parse the yum source, and an error occurs:

​​
Second, report the cause of the error
The machine cannot parse the yum source, for three reasons:
(1) The machine can not access the Internet! Please check the network configuration to make sure that you can surf the Internet and then look at the second situation. A simple point is ping a public network IP, such as ping 114.114.114.114 if ping does not work, is not on the network. If you can ping it, that would be the second case.


(2) DNS configuration problem! Nslookup www.baidu.com
nslookup www.baidu.com
nslookup www.baidu.com
nslookup www.baidu.com
nslookup www.baidu.com
nslookup www.baidu.com


(3) The machine can access the Internet, DNS configuration has also been configured, but still cannot resolve yum source, then you can change to a yum source and try again.
​​
Three, can’t access the Internet solution
(1) Check the network card name and enter the command:

(2) Start to modify the network information configuration file, open the configuration file, and enter the command:

vi /etc/sysconfig/network-scripts/ifcfg-Name of the network card
e.g:vi /etc/sysconfig/network-scripts/ifcfg-ens33


(3) Change ONBOOT=no to ONBOOT=yes

4. DNS configuration error solution
(1) This problem is caused by yum’s inability to resolve the domain name corresponding to the remote packet management library even though it has been connected to the Internet during the process of package installation. Therefore, we only need to add the IP address corresponding to DNS to the network configuration. Open the configuration file and enter the command:

vi /etc/sysconfig/network-scripts/ifcfg-Name

(2) Append DNS at the end of the file:

DNS1=8.8.8.8
DNS2=4.2.2.2

(3) Restart the network and enter the command:

ifup Name
e.g:ifup ens33

Read More: