Docker is a popular solution for packaging applicatiom containers, but it can work equally as well for building system containers.
I've tried using lxc, and then lxd, for this, but the former requires too much tweaking (e.g. to get networking going, with sparse and outdated documentation), and the latter chases docker in a not-very-serious way. It's also only available as a snap.
The problem with creating system containers with docker is that by default they shut down immediately after creation, because there's no app or service to keep it running.
To create a docker container from an O/S image that will keep running after creation, use this command: