docker in lxc container

limone

Member
Aug 1, 2017
61
0
6
25

atl

New Member
Dec 2, 2015
5
1
3
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
...
 

kcallis

New Member
Apr 5, 2018
21
0
1
51
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:

kcallis

New Member
Apr 5, 2018
21
0
1
51
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.
 

LnxBil

Well-Known Member
Feb 21, 2015
3,946
367
83
Germany
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.
 

Flysquid

New Member
Apr 20, 2019
1
0
1
36
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.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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 your own in 60 seconds.

Buy now!