Reference
https://github.com/lxc/lxcfs
LXD host
$ tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
|
install lxcfs
$ cat /etc/apt/sources.list.d/lxcfs.list
deb http://ppa.launchpad.net/ubuntu-lxc/lxcfs-stable/ubuntu trusty main
deb-src http://ppa.launchpad.net/ubuntu-lxc/lxcfs-stable/ubuntu trusty main
$ sudo apt-get update
$ sudo apt-get install lxcfs
$ ls /var/lib/lxcfs/
cgroup proc
$ ps aux | grep lxcfs | grep -v grep
root 2662 0.0 0.0 382476 1952 ? Ssl 8月29 3:43 /usr/bin/lxcfs /var/lib/lxcfs
|
Launch an instance ( Ubuntu 16.04 )
can’t use systemctl..
$ lxc launch ubuntu:16.04 test01 -e
Creating test01
Retrieving image: 100%
Starting test01
$ lxc exec test01 -- /bin/bash
root@test01:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
root@test01:~# systemctl reboot
Failed to connect to bus: No such file or directory
Failed to connect to bus: No such file or directory
Failed to connect to bus: No such file or directory
|
stop the container.
$ lxc stop test01 --force
|
edit /etc/lxc/default.conf
add the followings.
# add for systemd based containers
lxc.mount.auto = cgroup:mixed
lxc.autodev = 1
lxc.kmsg = 0
lxc.include = /usr/share/lxc/config/common.conf.d/00-lxcfs.conf
|
$ lxc launch 419af7170d66 -e test01
$ lxc exec test01 -- systemctl
Failed to connect to bus: No such file or directory
$ lxc stop test01 --force
|
restart lxd
$ sudo /etc/init.d/lxd restart
|
still can’t use systemclt.
$ sudo lxc launch 419af7170d66 test01 -e
$ lxc exec test01 -- systemctl
Failed to connect to bus: No such file or directory
|
$ lxc stop test01 --force
|
create a config file for this container.
# vi /var/lib/lxd/containers/test01/config
|
# cat /var/lib/lxd/containers/test01/config
lxc.mount.auto = cgroup:mixed
lxc.autodev = 1
lxc.kmsg = 0
lxc.include = /usr/share/lxc/config/common.conf.d/00-lxcfs.conf
|
start the container
$ lxc start test01
|
I was able to use systemctl ☺
$ lxc exec test01 -- systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
dev-sda1.device loaded activating tentative dev-sda1.device
-.mount loaded active mounted /
dev-.lxd\x2dmounts.mount loaded active mounted /dev/.lxd-mounts
|
$ lxc stop test01
$ lxc list test01
+--------+---------+------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+--------+---------+------+------+------------+-----------+
| test01 | STOPPED | | | PERSISTENT | 0 |
+--------+---------+------+------+------------+-----------+
|
CentOS7 container.
$ lxc init images:centos/7/amd64 test02
|
$ cat /var/lib/lxd/containers/test02/config
lxc.mount.auto = cgroup:mixed
lxc.autodev = 1
lxc.kmsg = 0
lxc.include = /usr/share/lxc/config/common.conf.d/00-lxcfs.conf
|
$ lxc start test02
$ lxc exec test02 -- cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
$ lxc exec test02 -- systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
-.mount loaded active mounted /
dev-.lxd\x2dmounts.mount loaded active mounted /dev/.lxd-mounts
|
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.