r/AlpineLinux • • Mar 28 '19

I migrated from a debian server to an alpine host system with LVM-based LXC containers. AMA.

I'm a professional sysadmin and learned about Alpine Linux about a year ago. As Alpine keeps every promise it makes (small, simple, secure), I decided to migrate my private servers completely, as far as possible. I ended up in a beatiful setup with an Alpine server hosting ~20 LXC containers, whereas most of them run alpine as well.

I have several containers for e.g. DHCP/DNS, mailserver, webserver, build containers (for Alpine packaging), monitoring (icinga+cacti) and much more – so it's more like a complete infrastructure on a single server.

AMA.

17 Upvotes

8 comments sorted by

1

u/grumpieroldman Mar 28 '19

Are you running anything using Tomcat and/or Apache?
e.g. Any issues hosting Jira/Confluence/Jenkins/et. al.

1

u/misterunkn0wn Mar 28 '19

I use many Apache instances without any problems. openjdk is available, as well as the tomcat application server, so I guess it should work – but I didn't try it myself yet. However, I use an Alpine container running Apache Guacamole with a jetty webserver which works fine.

One thing to notice: You can't run java applications when they depend on the native Oracle Java, because Oracles binary releases depend on glibc, and won't start with musl libc.

But in general, software which is build against glibc may run on alpine, as the Adobe Flash player does for example.

2

u/misterunkn0wn Mar 28 '19

Hm, I was curious about jenkins, so I decided to try it. It was as easy as:

apk add jenkins --upgrade-cache -y && /etc/init.d/jenkins start

It worked instantly, but I didn't try any features, yet.

Screenshot

1

u/[deleted] Mar 28 '19

I'm interested in creating setup very similar to yours for my private server(s) too. I installed Alpine in Virtualbox to try it out, but found it difficult (and I have no problem with text only Unix servers). What I think is my main obstacle is out-of-date or not-Alpine-specific tutorials and documentation.

So my first question - can you share or recommend some documentation for setting up LXC containers on Alpine linux? Do you have some tutorial which followed step-by-step with current Alpine will lead to functioning system?

Finally I was able to get Alpine guests on Alpine host working, but I couldn't get non-Alpine guests to work. Each different distro failed with its own specific error, usually missing some package specific for that distro (such as yum for CentOS guest).

So my second question, do you have non-Alpine guests running? Can you share some advice how to make at least one non-Alpine distro working?

Thanks in advance.

1

u/misterunkn0wn Mar 29 '19

So my first question - can you share or recommend some documentation for setting up LXC containers on Alpine linux?

Good question. The Alpine wiki helped me a lot, even if it is partly outdated. The IRC channel is great as well, great lads there (even ncopa, the Alpine creator)!

Do you have some tutorial which followed step-by-step with current Alpine will lead to functioning system?

Unfortunately not. While creating this setup I often changed the direction, and tried different ways etc. I put the "create a tutorial" task on my TODO list, but that would be another weekend I would have to spend, and didn't find the motivation, yet ;)

Finally I was able to get Alpine guests on Alpine host working, but I couldn't get non-Alpine guests to work.

As Alpine is systemd-free, you have to ensure that the systemd cgroup is mounted. Try this:

[ -e /sys/fs/cgroup/systemd ] || mkdir /sys/fs/cgroup/systemd
mount -t none -o rw,relatime,name=systemd cgroup /sys/fs/cgroup/systemd

If it works, you can simply add an suitable line to your /etc/fstab

1

u/[deleted] Mar 30 '19

Thank you, it works!

0

u/[deleted] Mar 28 '19

[deleted]

1

u/misterunkn0wn Mar 28 '19

How do you manage the Linux containers? Just with the cli (LXD?) or with something more structured

I neither use lxd nor any web frontend, but simply the LXC tools (lxc-create, lxc-ls, ...). I thought about using lxd, but it does not really fit my needs, as it has a more Docker-like approach.

Do you use Docker on these LXC images?

While it should be possible to run Docker in LXC containers, I don't do that, at least at the moment. I'm even not sure if that is a senseful mechanism. I guess it depends on your actual use-case. It definitely does not work out-of-the-box, because you have to configure some kernel-related cgroup things on a container which should contain another container.

What other tools do you use for persistence and reliability?

My setup is not high-available, but I already tested the possibility to use DRBD in connection with Heartbeat. In this case a hardware error would cause the other server to start the containers there. My setup is also not hyper-converged, so I can't move containers seamlessly between hostsystems.

The difference between LXC and Docker ist IMHO that LXC is more designed to containerize a whole OS, whereas Docker is designed to containerize a pecial application. You can use both of them either way, but you can see the idea by means of the toolchains.

0

u/[deleted] Mar 28 '19

[deleted]

1

u/misterunkn0wn Mar 28 '19

My idea was to simulate a "data center" with LXCs instead of virtual machines (managed by Proxmox)

That is not that complicated. You'd be astonished how easy it is to install such a setup with Alpine. I rent a dedicated root server with 2x 3TB hard drives. To install Alpine (with mdadm and LVM) I simply had to do setup-disk -L -s 2G -m sys /dev/sda /dev/sdb.

where each Linux Container has kubernetes and docker installed

Hm, I guess the LXC-layer wouldn't be necessary. You could simply install Kubernetes and Docker in the Alpine hostsystem and manage your containers there. There are some big differences between LXC containers and VMs. The biggest difference with the biggest impact is, that everything uses the same kernel. That should be considered when building a container farm.