Exported Container becomes hugh due lot of nearly identical subvolumes inside (docker btrfs)

Hi,
I run an docker compose project inside an lxc container on btrfs storage.
The general workflow works well (lxd snapshot) but export/copy didn’t

docker creates lot of subvolumes which mostly identical content.
Inside the container:

btrfs filesys du / -s 2>/dev/null 
     Total   Exclusive  Set shared  Filename
  41.28GiB    29.26MiB    12.74GiB  /

But if I export the lxc container, the archive is hugh.
Even with --instance-only --optimized-storage is ~30 GB.

Did anyone know a good solution/workaround?

There is a related issue for this (as both migrations and backups use the same optimized format):

At this current time I would recommend avoiding using Docker on BTRFS inside LXD if you need to migrate/backup efficiently.

If you use a storage pool driver like dir or lvm for your instance’s root disk, or just as a custom volume passed into the instance for use with the docker directory, then Docker can use overlayfs ontop of ext4 filesystem inside the container which will then be efficiently backed up.

See also