[lxc-users] "working" centos 7 container under ubuntu

Fajar A. Nugraha list at fajar.net
Tue Mar 3 12:56:33 UTC 2015


Hi,

Since systemd-219 is out, I decided to test it again for centos 7
container. It works cleaner than the previous attempt (218), no need
for custom hook script anymore.

Tested and works:
- container start & stop (privileged container)
- lxc-console
- lxc-attach
- login via ssh

unprivileged container still shows many errors (including errors about
systemd-journald and crash during poweroff), so I suggest you don't
use it for now.

Host:
- ubuntu 14.10, with ppa:ubuntu-lxc/daily
- lxc 1.1.0+master~20150224-0137-0ubuntu1~utopic, lxcfs
0.6-0ubuntu1~ubuntu14.10.1~ppa1

Built RPMs, dependency, and SRPM:
https://drive.google.com/folderview?id=0BzJrniucvUn3fmRYemdwYVdHUVFNTUN4V05LVmhEbGpjTWRhcTlkYm52VUU3WVpnZG9ndzg&usp=sharing

The original SRPM was from
http://koji.fedoraproject.org/koji/buildinfo?buildID=614896, with
added ubuntu patch for unprivileged container support from
http://packages.ubuntu.com/vivid/systemd

Steps:
- create the container (I use zfs, use whatever backing store you prefer)
# lxc-create -n c7 -B zfs --zfsroot=rpool/lxc -t download -- -d centos
-r 7 -a amd64

- edit container config file (e.g. /var/lib/lxc/c7/config), change
"centos.common.conf" to "fedora.common.conf"

- download RPMs to container root
download all files under RPMS-install in the above gdrive link. The
ones newly built are under "rebuild", while the ones under "centos"
and "fedora" are dependencies which can also be downloaded from your
prefered centos & fedora mirrors.

- chroot, and install downloaded RPMs
# chroot /var/lib/lxc/c7/rootfs
# rpm -Uvh RPMS-install/*/*.rpm
# exit

- start in foreground

# lxc-start -F -n c7
systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA
-APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL
+XZ -LZ4 +SECCOMP -BLKID +ELFUTILS +KMOD +IDN)
Detected virtualization 'lxc'.
Detected architecture 'x86-64'.

Welcome to CentOS Linux 7 (Core)!

Failed to install release agent, ignoring: No such file or directory
Running in a container, ignoring fstab device entry for /dev/root.
Overwriting existing symlink
/run/systemd/generator.late/netconsole.service with real service
Overwriting existing symlink
/run/systemd/generator.late/network.service with real service
Unit type .busname is not supported on this system.
Unit type .device is not supported on this system.
Unit type .automount is not supported on this system.
Unit type .swap is not supported on this system.
Cannot add dependency job for unit display-manager.service, ignoring:
Unit display-manager.service failed to load: No such file or
directory.
Cannot add dependency job for unit systemd-readahead-replay.service,
ignoring: Unit systemd-readahead-replay.service failed to load: No
such file or directory.
Cannot add dependency job for unit systemd-readahead-collect.service,
ignoring: Unit systemd-readahead-collect.service failed to load: No
such file or directory.
[  OK  ] Reached target Encrypted Volumes.
[  OK  ] Reached target Remote File Systems.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Swap.
[  OK  ] Created slice Root Slice.
[  OK  ] Listening on /dev/initctl Compatibility Named Pipe.
[  OK  ] Listening on Journal Audit Socket.
[  OK  ] Created slice User and Session Slice.
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Created slice System Slice.
         Starting Remount Root and Kernel File Systems...
         Starting Journal Service...
         Mounting Huge Pages File System...
[  OK  ] Created slice system-container\x2dgetty.slice.
         Mounting Temporary Directory...
         Mounting POSIX Message Queue File System...
[  OK  ] Reached target Slices.
[  OK  ] Listening on Delayed Shutdown Socket.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Mounted POSIX Message Queue File System.
[  OK  ] Mounted Huge Pages File System.
[  OK  ] Mounted Temporary Directory.
[  OK  ] Started Journal Service.
[FAILED] Failed to start Remount Root and Kernel File Systems.
See "systemctl status systemd-remount-fs.service" for details.
         Starting Configure read-only root support...
         Starting Create System Users...
         Starting Rebuild Hardware Database...
         Starting Rebuild Dynamic Linker Cache...
         Starting Load/Save Random Seed...
         Starting Flush Journal to Persistent Storage...
[  OK  ] Started Configure read-only root support.
[  OK  ] Started Create System Users.
[  OK  ] Started Rebuild Hardware Database.
[  OK  ] Started Rebuild Dynamic Linker Cache.
[  OK  ] Started Load/Save Random Seed.
[  OK  ] Reached target Local File Systems (Pre).
[  OK  ] Reached target Local File Systems.
         Starting Mark the need to relabel after reboot...
         Starting Rebuild Journal Catalog...
[  OK  ] Started Mark the need to relabel after reboot.
[  OK  ] Started Rebuild Journal Catalog.
         Starting Update is Completed...
[  OK  ] Started Flush Journal to Persistent Storage.
[  OK  ] Started Update is Completed.
         Starting Create Volatile Files and Directories...
[FAILED] Failed to start Create Volatile Files and Directories.
See "systemctl status systemd-tmpfiles-setup.service" for details.
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Started Update UTMP about System Boot/Shutdown.
[  OK  ] Reached target System Initialization.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Timers.
[  OK  ] Reached target Basic System.
         Starting Permit User Sessions...
         Starting Login Service...
[  OK  ] Started D-Bus System Message Bus.
         Starting D-Bus System Message Bus...
         Starting LSB: Bring up/down networking...
         Starting System Logging Service...
[  OK  ] Started System Logging Service.
[  OK  ] Started Permit User Sessions.
         Starting Cleanup of Temporary Directories...
[  OK  ] Started Container Getty on /dev/pts/0.
         Starting Container Getty on /dev/pts/0...
[  OK  ] Started Container Getty on /dev/pts/3.
         Starting Container Getty on /dev/pts/3...
[  OK  ] Started Container Getty on /dev/pts/1.
         Starting Container Getty on /dev/pts/1...
[  OK  ] Started Container Getty on /dev/pts/2.
         Starting Container Getty on /dev/pts/2...
[  OK  ] Started Console Getty.
         Starting Console Getty...
[  OK  ] Reached target Login Prompts.
[  OK  ] Started Cleanup of Temporary Directories.
[  OK  ] Started Login Service.
[  OK  ] Started LSB: Bring up/down networking.
[  OK  ] Reached target Network is Online.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Update UTMP about System Runlevel Changes.

CentOS Linux 7 (Core)
Kernel 3.16.0-29-generic on an x86_64

c7 login:


- set root password ( from another shell session):
# lxc-attach -n c7
# passwd
# exit

- login as root (back on centos login prompt)

- do whatever you want on your new centos system, terminate it (e.g.
using poweroff) when you're done

- next time you start the container, start it WITHOUT -f.


-- 
Fajar


More information about the lxc-users mailing list