2

I would like to create a new writable overlay from within a docker container. As the root filesystem in docker is already an overlay, it can't be used as the upperdir of another overlay. This answer suggests using tmpfs for the upperdir, and this works for me. However, I need to write more data than will fit in RAM, and this container has no swap space.

How can I create a writable overlay which is not limited by physical RAM?

I am far from an expert in Linux/Unix, so feel free to explain the basics.

1 Answer 1

1

Creating a writable overlay like this is inside of docker can be quite tricky.

One option you have is to use a volume or bind mount into the container. Inside the container these will not be an overlay so their respective directory can be used as an upper. That of course has a trip hazard if accidentally sharing the volume or failing to delete it after.

Another option is to manually a file as a loopback

  • truncate or fallocate a new file
  • mkfs.ext4
  • mount -o loop
2
  • Good clear answer! I'll accept this as it's a general solution although it didn't work for my situation. I can't use the first suggestion because I can't control how the container is launched, it's part of a Gitlab CI system. The manual loopback suggestion works initially but I notice it's modifying state on the host's device table which is not really suitable. I'm really surprised it's not possible to create and use a loop device entirely within the container without special permissions from the host. Commented May 1, 2023 at 0:00
  • @Roofus yes there's no device namespace in Linux (yet). I read somewhere that Linus Torvalds dislikes the need for loopback device and that the block layer cannot be passed through from the filesystem. But I don't know how true or current that was so I wouldn't hold your breath. Commented May 1, 2023 at 2:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.