- Edited
COMPLETLY OUT OF DATE
This howto is correct for 0.0.6 and superior release
Some assumptions :
- The daemon for cgmanager is running. you can find for s6 the package cgmanager-s6serv, just install and enable it. For runit you need to create your own by the classic way and put on you run file : exec /usr/bin/cgmanager. Or, you can start it on terminal by the command :
- Iptables is enabled on your s6.conf or, if you use runit, having the iptables service running : This is optional. It's only needed if you let the script configure the network for you (see below).
- Your system is up to date.
File path location/explanation :
- /etc/obarun/build.conf : file configuration for the container e.g password used and the creation of the bridge .
- /usr/share/obarun/templates/create : script used to create the container
- /usr/share/obarun/templates/create.conf : configuration file to create the container
- /usr/share/obarun/templates/cuztomize : script to configure the fresh installation onto the container
- /usr/share/obarun/templates/pkglist_base : list of package installed onto the container during the creation. Note: you can have multiple file as long as you keep the prefix pkglist_ e.g pkglist_service.
- /usr/share/obarun/templates/start : script used to start the container.
- /usr/share/obarun/templates/makepkg.conf : configuration file used by the container when you build a package AND copied onto the container after the fresh installation
- /usr/share/obarun/templates/pacman.conf : configuration file used by the container when you install package AND copied onto the container after the fresh installation
How to configure the network :
You can manage the network with the Manage network menu, see Manage Menu section below but it's important to know how to configure it manualy, so please don't skip reading those following lines.
The principal difficulty is to have a valid network onto the container.
Personnaly i don't use any "automatic program" dhcp-client, dhcpcd, network-manager or whatever to configure the network on my main system. I use iproute2 and my network is configured with static ip define in s6.local at boot time.
For example this is a part of my s6.local :
Anyway, the container can be created with a valid network automaticaly but some assumptions are made :
- All the variables concerning the network on build.conf are valid.
- You accept the fact that the script append your /etc/iptables.rules file with this e.g. :
The file /etc/obarun/build.conf need to be edited and change those variables :
create_bridge
router_addr
host_interface
host_addr
bridge_interface
bridge_addr
lxc_network_type, lxc_network_flags, lxc_network_link
lxc_network_ipv4
lxc_network_ipv4_gateway, lxc_network_name
this is what the script do with this all variables :
How to create a container :
to create it
----- Managing the network -----
Remenber, the interactive menu to manage the network use the variable set in /etc/obarun/build.conf. Be sure that you have correctly define it.
to show help
to show the network configuration
to see all command available
In fact all lxc-xxx command are available e.g
to log on it
to launch a command without logging on it
to destroy it
Your /var/cache/pacman/pkg is automaticaly mounted on the container.
How to build a package onto a container :
The variables source at /etc/obarun/build.conf must be set. Can be for example /var/abs/core
https://linuxcontainers.org/
https://github.com/lxc/lxc
https://wiki.archlinux.org/index.php/Linux_Containers
https://wiki.archlinux.org/index.php/Network_bridge
well, enjoy :)
As usual any feedback are welcome
This howto is correct for 0.0.6 and superior release
Some assumptions :
- The daemon for cgmanager is running. you can find for s6 the package cgmanager-s6serv, just install and enable it. For runit you need to create your own by the classic way and put on you run file : exec /usr/bin/cgmanager. Or, you can start it on terminal by the command :
$ sudo cgmanager
- Cgroups is enabled on your s6.conf or rc.conf- Iptables is enabled on your s6.conf or, if you use runit, having the iptables service running : This is optional. It's only needed if you let the script configure the network for you (see below).
- Your system is up to date.
File path location/explanation :
- /etc/obarun/build.conf : file configuration for the container e.g password used and the creation of the bridge .
- /usr/share/obarun/templates/create : script used to create the container
- /usr/share/obarun/templates/create.conf : configuration file to create the container
- /usr/share/obarun/templates/cuztomize : script to configure the fresh installation onto the container
- /usr/share/obarun/templates/pkglist_base : list of package installed onto the container during the creation. Note: you can have multiple file as long as you keep the prefix pkglist_ e.g pkglist_service.
- /usr/share/obarun/templates/start : script used to start the container.
- /usr/share/obarun/templates/makepkg.conf : configuration file used by the container when you build a package AND copied onto the container after the fresh installation
- /usr/share/obarun/templates/pacman.conf : configuration file used by the container when you install package AND copied onto the container after the fresh installation
How to configure the network :
You can manage the network with the Manage network menu, see Manage Menu section below but it's important to know how to configure it manualy, so please don't skip reading those following lines.
The principal difficulty is to have a valid network onto the container.
Personnaly i don't use any "automatic program" dhcp-client, dhcpcd, network-manager or whatever to configure the network on my main system. I use iproute2 and my network is configured with static ip define in s6.local at boot time.
For example this is a part of my s6.local :
# network stuff
ip link set enp2s0 up
ip addr add 192.168.178.2/24 broadcast 192.168.1.255 dev enp2s0
ip route add default via 192.168.178.1
with these few line i have the network configured and i do not have any daemon running just for a network :). Obviously you can use dhcpd on your system if you want.Anyway, the container can be created with a valid network automaticaly but some assumptions are made :
- All the variables concerning the network on build.conf are valid.
- You accept the fact that the script append your /etc/iptables.rules file with this e.g. :
-t nat -A POSTROUTING -o enp2s0 -j MASQUERADE
note : you can disable the auto-creation of the bridge into the file build.conf (see below)The file /etc/obarun/build.conf need to be edited and change those variables :
create_bridge
# Allow script to create a bridge automaticaly
# 0 for no, 1 for yes
create_bridge=1
allow the script to create or not the bridge automaticalyrouter_addr
# Address of the "router", meaning address of the box providing by your internet provider
router_addr="192.168.178.1"
to find your own :
obarun@ obarunS6 ~ % ip route
default via 192.168.178.1 dev enp2s0
192.168.178.0/24 dev enp2s0 proto kernel scope link src 192.168.178.2
the value after default via is your ownhost_interface
# Name of the host interface to use
host_interface="enp2s0"
nothing special here :)host_addr
# Address of the host interface
host_addr='192.168.178.2/24'
to fing your own
obarun@ obarunS6 ~ % ip addr | grep inet
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
inet 192.168.178.2/24 brd 192.168.1.255 scope global enp2s0
inet6 fe80::feaa:14ff:fe38:e0aa/64 scope link
the value after inet is your own (read the line comporting the name of your card e.g enp2s0)bridge_interface
# Name of the bridge
bridge_interface="lxc-nat"
name of the bridge when is created, you don't need to change thisbridge_addr
# Address of the bridge
bridge_addr='192.168.178.3/24'
as you can see the only difference between host_addr (192.168.178.2/24) and bridge_addr (192.168.178.3/24) is the last number before the /. So just increase your host_addr value e.g host_addr=192.168.100.3 bridge_addr=192.168.100.4lxc_network_type, lxc_network_flags, lxc_network_link
# Variable defined on the container configuration file when it created
# Type of the connection
lxc_network_type="veth"
# Name of the bridge used
lxc_network_link="${bridge_interface}"
# Allow using it directly
lxc_network_flags="up"
you don't need to change those variables.lxc_network_ipv4
# Address of the interface used onto the container
lxc_network_ipv4="192.168.178.4/24"
like made with bridge_addr, you just need to increase your bridge_addr value e.g bridge_addr=192.168.100.4 lxc_network_ipv4=192.168.100.5lxc_network_ipv4_gateway, lxc_network_name
# Gateway used by the interface onto the container, it should the same as the router_addr
lxc_network_ipv4_gateway="${router_addr}"
# Name of the interface onto the container
lxc_network_name="eth0"
you don't need to change those variables.this is what the script do with this all variables :
ip link add name "${bridge_interface}" type bridge
ip link set "${bridge_interface}" up
ip addr add "${bridge_addr}" dev "${bridge_interface}"
ip link set "${host_interface}" master "${bridge_interface}"
then append the /etc/iptables.rules files (see above).How to create a container :
to create it
$ sudo obarun-build Create create foo
This command line can be
$ sudo obarun-build C c foo
How to manage a container/network with the Manage interactive menu :----- Managing the network -----
Remenber, the interactive menu to manage the network use the variable set in /etc/obarun/build.conf. Be sure that you have correctly define it.
$ sudo obarun-build Manage network
This command line can be
$ sudo obarun-build M network
or
$ sudo obarun-build M n
You should have this on your terminal :
Type help to see option to control the bridge
Type quit for exit
Manage network >
We have to information here, first we are on Manage menu and we currently managing the network.to show help
Manage network > help
to create a bridge
Manage network > create
This command create and start the bridge.to show the network configuration
Manage network > show
to destroy it
Manage network > destroy
to stop it
Manage network > stop
to start it
Manage network > start
----- Managing a container -----$ sudo obarun-build Manage foo
This command line can be
$ sudo obarun-build M foo
TIPS: if you don't set the container name, the script ask you to pick one on a available container list.You can do this :
$ sudo obarun-build Manage
You should have this on your terminal :
Type help to see option
Type quit for exit
Manage foo >
We have to information here, first we are on Manage menu and we currently managing foo container.to see all command available
Manage foo > help
to switch between available container
Manage foo > switch foother
TIPS: if you don't set the container name, the script ask you to pick one on a available container list.You can do this :
Manage foo > switch
to start the managed container
Manage foo > start
This command line can be
$ Manage foo > start --logfile foo.log
to see the extra option for start command
$ Manage foo > start --help
We are currently managing the foo container container but we can temporarily manage an another container like this:
$ Manage foo > start -n foother
This command start the container foother.In fact all lxc-xxx command are available e.g
$ Manage foo > info -s -p
or
$ Manage foo > info --help
[/b]to log on it
$ Manage foo > console
CTRL+a then press q to go outto launch a command without logging on it
$ Manage foo > attach -- ping google.com
to stop it
$ Manage foo > stop
or for kill it
$ Manage foo > stop -k
A good practice is to shutdown the container with e.g. poweroff when you are logged on it or by the lxc-attach command before calling the lxc-stop commandto destroy it
$ Manage foo > destroy
to create a new container with another template
$ Manage foo > create -n gentoo -t /usr/share/lxc/templates/lxc-gentoo
The rootfs of the container can be found at /var/cache/obarun/pkgbuild/foo/container/rootfs. This directory is the / of system container. You can easily transfer what you want between your host and the container e.g a PKGBUILD. This location can be modified into the file build.confYour /var/cache/pacman/pkg is automaticaly mounted on the container.
How to build a package onto a container :
The variables source at /etc/obarun/build.conf must be set. Can be for example /var/abs/core
$ sudo obarun-build Build build foo
This line can be
$ sudo obarun-build B b foo
This command create a container named foo, build the package named foo on it then save the resulting package onto the path defined by the variable result_pkg into /etc/obarun/build.conf e.g. /var/cache/obarun/pkg/foo-0.1-1.pkg.tar.xzhttps://linuxcontainers.org/
https://github.com/lxc/lxc
https://wiki.archlinux.org/index.php/Linux_Containers
https://wiki.archlinux.org/index.php/Network_bridge
well, enjoy :)
As usual any feedback are welcome