0

I am running a database (CouchDB) from a Docker container on Unix (AWS EC2). For the database files, I have created an 'external' (ie. external to the container, but on the same host) volume which is mounted to the database inside the Docker container.

Does ulimit -f control/restrict file sizes for files created by this database running inside the Docker container but saved to the 'external' volume on the host? The only information I can find suggests ulimit -f only restricts parameters for files run through 'the shell or its children'. Is the Docker container considered to run through the shell?

If this will not work, is there any other way to restrict file sizes for my circumstance?

1 Answer 1

0

The size limit is applied to the process and it's children, not to the filesystem itself. From the perspective of the process inside the container, the different volumes are different mounted directories, and limits apply to all filesystems.

I don't believe I've seen anyone limit the max file size with ulimit, but see no reason it wouldn't work.

Typically, if a sysadmin is concerned of disk space usage by a container, they often isolate the volume to a partition on the host of a limited size. Mounting /var/lib/docker as a separate partition is common on docker hosts. Filesystem quotes may also be enabled if the filesystem supports them. And for the more granularity, a loop device may be created to mount a fixed size file with it's own filesystem. Each of these options needs to be configured on the host outside of docker and then the volume mounted from that restricted environment. These all have the advantage over ulimit in that they limit the total filesystem space, rather that the max a single file can grow, and they only limit that volume without limiting other directories inside the container.

1
  • Great info, thx. My host volume is of a fixed size, but is to be shared between a large number of users of the database. While CouchDB allows for one database file per user, it inexplicably does not have a method of restricting the size of the db file itself. My concern is one user can then gobble up the entire host volume with their own database file, leaving nothing for other users, hence the desire to limit file sizes. The filesystem quotas and loop device suggestions are great, but still seem to limit total space as opposed to individual file size, which is what I think I need. Commented Dec 2, 2019 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .