If you take a look at the scripts in discourse/bin/docker at main · discourse/discourse · GitHub
boot_dev creates and runs a container in detached mode, and rails/rake/etc utilizes docker exec to run the respective commands in the existing container, which are intended to make running those commands easier.
As for the Dockerfile question, it is answered in the README linked before: discourse/bin/docker/README.md at main · discourse/discourse · GitHub
There is a folder d at the project root symlinked to bin/docker, thus you can actually do d/boot_dev, d/rails s, etc.