How to limit container root disk size?

Hi, I had a few containers running in a host. I wanted to limit one of the container root disk size. However, when i run the command below, it said “device doesnt exist”. I assume this is because the root disk is inherited from profile ‘default’. Because this profile is used by all container in the host, is it possible to just limit a specific container size instead of all?
lxc config device set my-container root size 20GB

some environment information
driver: lxc
driver_version: 3.0.3
kernel: Linux
kernel_architecture: x86_64
kernel_version: 5.0.0-1025-gcp
server: lxd
server_pid: 1060
server_version: 3.0.3
storage: zfs
storage_version: 0.7.12-1ubuntu5
server_clustered: false

Yes you can do this:

lxc config device override <container> root size=20GB

This copies the root device from the profile into the container and then modifies the size key.

2 Likes

Thanks. It works. :grinning:

1 Like

I just don’t get one thing, using BTRFS, I tried to do this:

lxc profile device set default root size=15GB

lxc profile show default
(..)
  root:
    path: /
    pool: lxd
    size: 15GB
    type: disk
name: default

lxc launch debian12 debtest

And the created container doesn’t seem to have any limit on the root size. I was expecting a df command inside the container to show the root as 15GB.

Why?

1 Like

This does not work for me either.

How am I supposed to limit root disk size of individual container on default dir pool?