Loop devices are provided by a kernel module. Therefore, you need special privileges to access them. You also need them to be exposed into your container, or you need to manually create the device files.
The quick answer
docker run --privileged=true ...
An alternative
sudo losetup /dev/loop0 test.img
mount /dev/loop0 /mnt
docker run -v /mnt:/mnt ...
This almost works
docker run --device=/dev/loop-control:/dev/loop-control --device=/dev/loop0:/dev/loop0 --cap-add SYS_ADMIN ...
However I get this error:
root@5c033d5f8625:/# sudo mount /dev/loop0 /mnt
mount: block device /dev/loop0 is write-protected, mounting read-only
mount: cannot mount block device /dev/loop0 read-only
See this link for more information.
A note on systemd-nspawn man page:
systemd-nspawn limits access to various kernel interfaces in the
container to read-only, such as /sys, /proc/sys or /sys/fs/selinux.
Network interfaces and the system clock may not be changed from within
the container. Device nodes may not be created. The host system cannot
be rebooted and kernel modules may not be loaded from within the
container.