Installing services in an LXC container

Hi everyone!

For my group’s capstone project, we’ve installed the Centos 7 operating system on our servers and switches. So far we’ve managed to install LXC and create some containers, and configure networking settings for them, but are trying to figure out what to do next in order to install services (such as SMTP, SQL, Web Server, etc.) within the containers.

I’ve been researching for an hour and a half, but the only tutorials I can find cover setting up services on the Centos operating system itself, and configuring LXC containers.

What I’m trying to find out is whether there is anything I need to do differently in order to install services within an LXC container. Is there any difference, or can I simply just start and go into a container (switch from “[root@server~]#” to “[root@container_name~]#”), and start configuring with commands?

As a side note, we have been unable to log into our containers, as explained in this post:

Our current workaround for getting into the containers is the command:
[root@container_name ~]# lxc-attach -n container_name
Will that be an issue for configuring services in the LXC containers?

by command line type:

  • lxc exec containername bash

and you are IN the container. Now you can install and configure your system services as usual.

This is strange. Despite executing the following commands:
[root@localhost ~]# yum install epel-release
[root@localhost ~]# yum install debootstrap perl libvirt
[root@localhost ~]# yum install lxc lxc-templates
[root@localhost ~]# lxc-create -n Email -t centos

This still happened when I tried to list existing lxc containers:
[root@localhost ~]# lxc-ls
bash: lxc-ls: command not found…


You are using LXC instead of LXD (which is easier). With LXD, the commands are like lxc launch ubuntu:18.04 mycontainer instead of lxc-create.

Then, you can install any services in the containers and expose them to the network. You can do so either with iptables, with a proxy like haproxy or even with the LXD built-in proxy.

You know I’m using Centos 7 with Red Hat, right? Well, this happened:

If you really need to use Centos, then I suggest to use these instructions instead,

These instructions are about LXD (not LXC), which is simpler and easier to use.

I’m now trying to install email using this tutorial, but when I enter the second command in the tutorial:
yum -y install --disablerepo=epel*

It keeps telling me that I need to pass a list of pkgs to install. I’ve tried all 3 aliases, and nothing works:

Should I just ignore this and keep going?

You should first make sure that your tutorial is correct; the yum command does not seem fine to me, the package to install is nowhere to be seen.
It is not on topic for a forum about lxc/lxd to ask help on a tutorial on mail installation.