使用lxc-create -t centos --name centos1 -- -- release 7 --arch x86_64创建centos7的的lxc容器时给我报错
Host CPE ID from /etc/os-release: cpe:/o:centos:centos:7
Checking cache download in /var/cache/lxc/centos/x86_64/7/rootfs ...
Downloading CentOS minimal ...
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
One of the configured repositories failed (未知),
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. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, 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>
or
subscription-manager repos --disable=<repoid>
5. 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
mv: 无法获取"/var/cache/lxc/centos/x86_64/7/partial/var/run/*" 的文件状态(stat): 没有那个文件或目录
rmdir: 删除 "/var/cache/lxc/centos/x86_64/7/partial/var/run" 失败: 不是目录
Reinstalling packages ...
mkdir: 无法创建目录"/var/cache/lxc/centos/x86_64/7/partial/etc/yum.repos.disabled": 文件已存在
mv: 无法获取"/var/cache/lxc/centos/x86_64/7/partial/etc/yum.repos.d/*.repo" 的文件状态(stat): 没有那个文件或目录
mknod: "/var/cache/lxc/centos/x86_64/7/partial//var/cache/lxc/centos/x86_64/7/partial/dev/null": 文件已存在
mknod: "/var/cache/lxc/centos/x86_64/7/partial//var/cache/lxc/centos/x86_64/7/partial/dev/urandom": 文件已存在
chroot: failed to run command ‘yum’: No such file or directory
Failed to download the rootfs, aborting.
Failed to download 'CentOS base'
failed to install CentOS
lxc_container: lxccontainer.c: create_run_template: 1092 container creation template for centos1 failed
lxc_container: lxc_create.c: main: 274 Error creating container centos1
我寻思这应该是yum源的问题,可是我之前不是把yum源给换成了阿里的了吗。后来在/var/cache/lxc目录下看到安装该容器所下载的软件包,最后定位到/var/cache/lxc/centos/x86_64/7/partial/etc/yum.repos.d目录下的lxc-centos-temp.repo文件,
[root@lhr01 yum.repos.d]# cat lxc-centos-temp.repo
[base]
name=CentOS-7 - Base
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os
[updates]
name=CentOS-7 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates
才知道是这里出现的问题。当我尝试修改这个文件将其换为阿里的yum源配置,再运行lxc-create -t centos --name centos1 -- -- release 7 --arch x86_64时还是不行,这个lxc-centos-temp.repo文件会被重新覆盖为原来的样子。所以关于centos7容器的创建目前还不知道该如何处理,留下此文做一个记录