feat: have docker filesystem be read/writeable but limited in space
See original GitHub issueObviously the overall disk space that an execution can consume has to be limited. Otherwise we would be open for easy attacks that basically just write as much data into the filesystem until the host filesystem is full.
Unfortunately, by the time we started MachineLabs our options with docker to limit the overall filesystem size of an container were rather limited.
So, what we currently do can be summed up as follows:
-
Technically there is no overall limit of disk space inside an execution. Each execution “sees” the entire available disk space of the host.
-
However, the filesystem of the container is readonly preventing the user from writing anything to disk.
-
As an exception to the second point, the filesystem can write into
/run
and/tmp
. This is possible by mounting these directories as--tmpfs
for wich we can specify constraints on the size.
Unfortunately this still prevents us from doing simply things such as installing further software with pip
(unless the user figures out how to install it in either /run
or /tmp
which seems to be hard to achieve)
Today, the situation on the docker front looks a bit better actually. Docker allows a parameter such as '--storage-opt size=10G'
to limit the overall disk space of a container.
However, if that works depends on the underlying storage driver that is used. I failed to get that working on both my local environment as well as on the staging system because the systems did not match the requirements. I think we should get that working with the overlay2
storage driver over an ext4
system but would be require to upgrade our docker version.
I don’t wanna go that rabbit whole right now so I thought I write down my findings.
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (20 by maintainers)
Top GitHub Comments
I was able to mount a second volume, format it as xfs, change the docker directory to the second volume and this is what
docker info
returned.As you can see, it’s
overlay2
backed withxfs
, exactly what we need! The only thing that I need to do now is figuring out what thepquota
mount option is.@cburgdorf These are the steps I followed on GCP. I believe it worked, but after creating an image with
storage-opt
, I’m not sure how I can verify that I limited my disk space.If something is not clear, let me know and I’ll update the steps.