LXC - 无法从 linux 容器访问包管理器

LXC - Can't access package manager from linux container

我在 fedora 27 机器上安装了 LXD。我不久前配置了它,它运行良好,以至于我忘记了我是如何设置一切的。我刚刚尝试创建一个新容器并成功创建,但我无法让它访问包管理器。我依稀记得这是我在安装所有内容时创建其他容器时出现的问题,但我不记得我是如何修复它的。截至目前,我的其他旧容器工作正常,并且可以访问包管理器,一切正常。但是当我创建一个新容器时,它就像包管理器不存在一样。

如何使用 LXD 将包管理器安装到新的 Linux 容器?

谢谢,

-Yurelle

[root@neon ~]# lxc launch images:fedora/27 myThing
Creating myThing
Starting myThing
[root@neon ~]# lxc exec myThing bash
[root@myThing ~]# apt
bash: apt: command not found
[root@myThing ~]# apt-get
bash: apt-get: command not found
[root@myThing ~]# yum
bash: yum: command not found
[root@myThing ~]# rpm
RPM version 4.14.1
Copyright (C) 1998-2002 - Red Hat, Inc.
This program may be freely redistributed under the terms of the GNU GPL

Usage: rpm [-afgpcdLAlsiv?] [-a|--all] [-f|--file] [-g|--group] [-p|--package] [--pkgid] [--hdrid] [--triggeredby] [--whatrequires] [--whatprovides] [--whatrecommends]
        [--whatsuggests] [--whatsupplements] [--whatenhances] [--nomanifest] [-c|--configfiles] [-d|--docfiles] [-L|--licensefiles] [-A|--artifactfiles] [--dump] [-l|--list]
        [--queryformat=QUERYFORMAT] [-s|--state] [--nofiledigest] [--nofiles] [--nodeps] [--noscript] [--allfiles] [--allmatches] [--badreloc] [-e|--erase=<package>+]
        [--excludedocs] [--excludepath=<path>] [--force] [-F|--freshen=<packagefile>+] [-h|--hash] [--ignorearch] [--ignoreos] [--ignoresize] [-i|--install] [--justdb]
        [--nodeps] [--nofiledigest] [--nocontexts] [--nocaps] [--noorder] [--noscripts] [--notriggers] [--oldpackage] [--percent] [--prefix=<dir>] [--relocate=<old>=<new>]
        [--replacefiles] [--replacepkgs] [--test] [-U|--upgrade=<packagefile>+] [--reinstall=<packagefile>+] [-D|--define='MACRO EXPR'] [--undefine=MACRO] [-E|--eval='EXPR']
        [--target=CPU-VENDOR-OS] [--macros=<FILE:...>] [--noplugins] [--nodigest] [--nosignature] [--rcfile=<FILE:...>] [-r|--root=ROOT] [--dbpath=DIRECTORY] [--querytags]
        [--showrc] [--quiet] [-v|--verbose] [--version] [-?|--help] [--usage] [--scripts] [--setperms] [--setugids] [--conflicts] [--obsoletes] [--provides] [--requires]
        [--recommends] [--suggests] [--supplements] [--enhances] [--info] [--changelog] [--changes] [--xml] [--triggers] [--filetriggers] [--last] [--dupes] [--filesbypkg]
        [--fileclass] [--filecolor] [--fileprovide] [--filerequire] [--filecaps]
[root@myThing ~]# exit
exit
[root@neon ~]# lxc info myThing
Name: myThing
Remote: unix://
Architecture: x86_64
Created: 2018/06/09 22:24 UTC
Status: Running
Type: persistent
Profiles: default
Pid: 32310
Ips:
  eth0: inet    10.0.1.234      veth62EL09
  eth0: inet6   fe80::216:3eff:fe13:5c02        veth62EL09
  lo:   inet    127.0.0.1
  lo:   inet6   ::1
Resources:
  Processes: 7
  Disk usage:
    root: 7.71MB
  CPU usage:
    CPU usage (in seconds): 0
  Memory usage:
    Memory (current): 37.62MB
    Memory (peak): 39.65MB
  Network usage:
    eth0:
      Bytes received: 10.46kB
      Bytes sent: 3.68kB
      Packets received: 77
      Packets sent: 36
    lo:
      Bytes received: 510B
      Bytes sent: 510B
      Packets received: 6
      Packets sent: 6
[root@neon ~]#

好吧,我是个白痴,Fedora 镜像默认使用 DNF 包管理器。所以,要么使用它,要么使用它来安装 yum:

[root@neon ~]# lxc launch images:fedora/27 myThing
Creating myThing
Starting myThing
[root@neon ~]# lxc exec myThing bash
[root@myThing ~]# dnf update
Last metadata expiration check: 0:42:05 ago on Sat Jun  9 22:24:14 2018.
Dependencies resolved.
Nothing to do.
Complete!
[root@myThing ~]# dnf install yum
Last metadata expiration check: 0:42:12 ago on Sat Jun  9 22:24:14 2018.
Dependencies resolved.
...