The supported way to run it is to follow the standard install. If you want a local/development insurance with no hostname, see Install Discourse for development using Docker.
If you want to install using docker compose, build an image with launcher, put it somewhere docker compose can get it and have at it. There is a launcher command that will print out the necessary env values. You can read the launcher source to get the command, as I can’t remember if.
See also Can Discourse ship frequent Docker images that do not need to be bootstrapped?