Using Docker Ubuntu image to learn Linux system-networking

Posted on


Docker being an application container and not a system container like LXD, is it possible to use a Linux OS Docker image (say, for Ubuntu or Centos) to teach myself Linux, OS-level networking by creating a bunch of lightweight instances and then experimenting with things like NAT, bridging, routing, proxies (various kinds), firewall (iptables)… ?

Basically, I do not want to use a heavyweight solution like VirtualBox because I would like to be able to have multiple Linux OS instances in various setups, so the lighter my instances the better.

With LXD, the one issue I see is: Unless I use ZFS or BTRFS type file-system, I won’t be able to save on disk space.

EDIT: My host OS is Ubuntu 20.04, not Windows.


Quick answer: Yes.

As far as networking is concerned, Docker containers and LXC/LXD containers are both good for your purpose.

Containers on Linux are implemented with various isolation techniques, including namespaces, seccomp, cgroup, among others. The core here is network namespace (CLONE_NEWNET in clone(2)), which creates an exact copy of the host’s network stack, with an independent set of network interfaces, routing tables and rules, firewall (iptables or netfilter) etc., making it suitable for experimenting with network setup.

The only thing to note is that containers usually don’t have access to “dangerous” actions to the host kernel, like managing kernel modules. For this reason, if you’re experimenting with stuff like WireGuard, you’ll have to install the module on the host side. Other than that I see no problem doing network experiments with containers, be it Docker or LXD.

For your concern of configuring and maintaining ZFS / Btrfs, I recommend going with LXD (installed from Snapcraft) which comes with ZFS support. Using the default setup guide (lxd init), you’ll be able to create a “virtual disk” in ZFS format that supports all the advanced features, while remaining as simple as a single file in your host system. It should reside in /var/snap/lxd/common/lxd/disks. (I can’t remember too man details on this because I’ve since migrated my host setup to ZFS so I’m using ZFS directly).

Leave a Reply

Your email address will not be published. Required fields are marked *