centos7 linux 执行yum (虚拟机下)

[root@sh04181125 network-scripts]# yum install docker
Loaded plugins: fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
12: Timeout on http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock: (28, 'Resolving timed out after 30982 milliseconds')

One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

 1. Contact the upstream for the repository and get them to fix the problem.

 2. Reconfigure the baseurl/etc. for the repository, to point to a working
    upstream. This is most often useful if you are using a newer
    distribution release than is supported by the repository (and the
    packages for the previous distribution release still work).

 3. Disable the repository, so yum won't use it by default. Yum will then
    just ignore the repository until you permanently enable it again or use
    --enablerepo for temporary usage:

        yum-config-manager --disable <repoid>

 4. Configure the failing repository to be skipped, if it is unavailable.
    Note that yum will try to contact the repo. when it runs most commands,
    so will have to try and fail each time (and thus. yum will be be much
    slower). If it is a very temporary problem though, this is often a nice
    compromise:

        yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64
[root@sh04181125 network-scripts]# ping www.baidu.com
ping: unknown host www.baidu.com
内网是通的

修改/etc/resolv.conf内容如下:
nameserver 8.8.8.8

@topsre 试过了,不行!

ping 8.8.8.8能通吗?

你这个是内网这台机器不能访外网的话 使用 yum 是不行的,可以采用离线安装 参考:http://www.cnblogs.com/aguncn/p/6863710.html

1、虚拟机的话你可以配置NAT上网方式
2、虚拟机那边你可以开启dhcp,然后centos7 下 将网卡开启自动获取ip的方式
3、如果2(自动获取ip的方式)不行,你配置指定的网卡为静态,静态的IP得看你虚拟机那边配的网段是多少,然后根据网段来配置ip,
网关的话,一般是192.168.x.2 DNS服务器也是配置这个参数,这样子差不多就能上网了

  1. 虚拟机网络适配器,选择桥接模式。
  2. 修改centos网络配置文件vi /etc/sysconfig/network-scripts/ifcfg-eth0,参照电脑网卡配置好ip,网关,dns等信息,再执行service network restart。(有可能网卡不是eth0,可以执行ifconfig命令查看)
  3. ping www.baidu.com 验证虚拟机是否可以上网了,如果还不行,可能需要重启虚拟机,手动修改dns配置文件,或者网络有mac地址绑定,需联系网管解决。 图片说明图片说明

外网不通。可能是被墙了。
这种问题在docker官网也有解决办法提供。
1,也是比较推荐的办法。就是离线包安装docker。就是下载最新的docker的rpm包,通过rpm -ivh *.rpm 命令即可安装
2. 有条件的话直接开代理。