Skip to content

Add tmpfs support for disk devices #1822

@huoxingdawang

Description

@huoxingdawang

I noticed that Incus has recently supported OCI images, like Docker, and I really like this feature.
However, I noticed that many Docker configurations include something like --mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 to create a temporary directory within the container.

Currently, a feasible alternative may be to map all containers to the host's tmpfs using the "path" mode.
But if all containers share the same directory on the host, some containers may not work properly. For example, multiple copies of the same application would try to access the same directory.
If each container has its own tmpfs on the host, I need to manually create all the directories, which is inconvenient to maintain.
And for both methods, after restart the containe, the files will be kept rather than deleted.

For system containers with complete distributions, I can create tmpfs within the container, such as editing /etc/fstab. But this approach doesn't seem effective for applications, as they do not handle the content in /etc/fstab.

I'm not sure if there's already a solution for this, but if not, I suggest adding tmpfs support for disk devices. For example, the configuration could look like this, and we can get a 8GB temporary directory within the container:

devices:
  tmpfs:
    path: /tmp
    source: tmpfs
    size: 8GB
    type: disk

Metadata

Metadata

Assignees

Labels

APIChanges to the REST APIDocumentationDocumentation needs updatingEasyGood for new contributors

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions