Another search in the forum revealed this topic:
So, I rebooted the container and finally was able to nixos-rebuild switch without an error.
nixos-rebuild switch