Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

LXC in Slackware

June 08, 2023 — Gregg Szumowski

Following directions from: lxc for Slackware 14.2. I haven’t tested on Slackware 15 yet. You will have to set this up while running as root.

  1. Create the file '/etc/default/lxc-net' and add the line USE_LXC_BRIDGE="true" to it.

  2. Create the directory '/var/lib/misc'

  3. Start the service: # /usr/libexec/lxc/lxc-net start

  4. Create a config file:

# cat >slac-xlc.con <<“EOF”
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
EOF

  1. Create the container:

# arch=x86_64 release=14.2 MIRROR=http://mirrors.us.kernel.org/slackware lxc-create -n Slackware64-14.2 -t slackware -f slack-xlc.conf

  1. Start the container for the first time:

# lxc-start -n Slackware64-14.2

  1. Login to the container:

# lxc-console -n Slackware64-14.2

or

# lxc-attach -n Slackware64-14.2

The difference between these two methods is that using the first you will require a username and password (root and root, in this case) and with the latter you won’t.

  1. The first thing you will need to do is set up the container to connect to the network. Edit '/etc/rc.d/rc.inet1.conf' and update the USE_DHCP entry for 'eth0' to USE_DHCP[0]="yes".

  2. Restart the container and verify connectivity.

# lxc-stop -n Slackware64-14.2 && lxc-start -n Slackware64-14.2

  1. Login to the container and use ‘ping’ to verify connectivity.

Tags: slackware, lxc, containers, motd