docker in lxc container

limone

Well-Known Member
Aug 1, 2017
89
9
48
30
It works! you can use aufs or overlay file system. For using it within a LXC container, you have to load the module on the proxmox host. I've inserted it into /etc/modules-load.d/modules.conf :
Code:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
aufs
overlay
After reboot you can check, if the module was loaded:
Code:
root@proxmox:~# lsmod | grep -E 'overlay|aufs'
overlay                77824  8
aufs                  237568  0

Within the LXC container the same command should show, that the modules are loaded. Then change the docker configuration /etc/docker/daemon.json to use the wanted filesystem. I'm using overlay file system within LXC:
Code:
root@lxc:~# cat /etc/docker/daemon.json
{
  "storage-driver": "overlay2"
}
After restart docker service you can see with docker info, if it works:
Code:
root@lxc:~# docker info
Containers: 18
 Running: 0
 Paused: 0
 Stopped: 18
Images: 4
Server Version: 17.05.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
...
 
I happened to run across this thread when I was looking around for the same topic. Since I am using pve on a laptop, I am always looking for ways to reduce resource usage. If I read this correctly, I could spin up a ubuntu 18.04 lxc container, and from there, install docker. I am trying to better understand docker and especially storage, my question is this: Assuming that I make the aforementioned container with 25G allocated, how does on create a docker container and make use of the storage outside of the container? For instance, if I were to spin up portainer, that is not an issue because it is relatively light on storage usage. But after this, I spin up postgreSQL and then create a 50G database, if my lxc container is only 25G, how would I make use of the storage on the host (pve with the thin-kvm or local) to store my database?
 
Last edited:
I currently have docker sitting on the pve body. I decided to docker based version of atomic toolkit which is various media apps like plex, Sabnzbd, sonarr, etc. Lots of ports to keep track of, and more importantly, as I add more apps, there is more complexity. For instance, say I wanted to bring a docker image of WordPress. I would have to deal with changing port, etc.

I would rather do is create a lxc container called media (Ubuntu 18.04 image) and then docker based atomic toolkit and know to connect to http://media:5000 or http://media:32400 to get to Plex. Then I can spin up another lxc image and dockerize Nagios and other monitoring apps and get that running with minimal changes.
 
But after this, I spin up postgreSQL and then create a 50G database, if my lxc container is only 25G, how would I make use of the storage on the host (pve with the thin-kvm or local) to store my database?

You cannot.

If you're not so concerned about hypervisor security (you're on a laptop, so you normally don't), just run Docker on your host as @morph027 suggests. Best is to use Docker with ZFS so that you can have quota and separation on storage level.
 
I've been able to run docker in an LXC and have the docker container access the host storage. Whatever storage you want mounted to the host, you'd mount it to the LXC. Once the LXC can see the storage, you can start a docker container to access the mounted path. I do this for my docker container to see my nfs share.

As to the questions of why not just install docker on the host alongside PVE? Because I like the separation. The container can be backed up and migrated. The host can die or I tweak PVE incorrectly and have to reinstall. Being a home environment and no external access in, my concern for security is a minimal. I am hosting for me.
 
Having the same problem here. Ran the "modprobe overlay" on the host, verified presense in the container, but docker still fails with a not-very-helpful error message:

Code:
Oct 18 22:57:31 docker2 systemd[1]: Starting Docker Socket for the API.
Oct 18 22:57:31 docker2 systemd[1]: Listening on Docker Socket for the API.
Oct 18 22:57:31 docker2 systemd[1]: docker.service: Start request repeated too quickly.
Oct 18 22:57:31 docker2 systemd[1]: docker.service: Failed with result 'exit-code'.
Oct 18 22:57:31 docker2 systemd[1]: Failed to start Docker Application Container Engine.
Oct 18 22:57:31 docker2 systemd[1]: docker.socket: Failed with result 'service-start-limit-hit'.

The overlay driver is present.

Code:
root@docker2:~# lsmod | grep overlay
overlay               114688  0

If I remove the daemon.json with the overlay2 line it starts fine, but of course using vfs storage driver, which is super inefficient.
Any ideas?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!