What's the purpose of DISCOURSE_HOSTNAME env?

I’ve been experimenting a bit with Discourse installation. I noticed that by default the Docker container is started with the DISCOURSE_HOSTNAME environment variable. I tried to start the container without this env and it works fine as well.

I tried to look for this env in the code repository, but the results are not really interesting. (https://github.com/discourse/discourse/search?q=DISCOURSE_HOSTNAME)

What is the purpose of this env?

Similarly, I also tried removing the --mac-address setting from docker’s run command - the app works as before. Why is --mac-address needed?

I’m pretty sure that makes hostname appear in the config/discourse.conf file. I’d recommend that you always set it.

The --mac-address is something of a mystery to me. I think it has to do with something in their internal hosting. I’m pretty certain that it’s safe to leave that off.

1 Like

Consistent MAC addresses on the containers would give us consistent container IPv6 addresses which is useful when replacing containers during a deployment.

I don’t think it’s used for anything else.

You can skip it if you don’t need it.


Ooooh! The mystery is solved! And a chance to see Matt Palmer! If I had 100 likes, I’d apply them here.

@pfaffman Could you say something more about the config/discourse.conf file? What is its purpose? I saw some references to it on the Internet, but it seems like it is something similar to containers/app.yml?

What will happen in practice if I do not provide DISCOURSE_HOSTNAME?

Another thing I realized - by default Discourse also is being run with the DOCKER_HOST_IP env. Again, I removed it, and Discourse works fine. I suppose that this one is somehow used during Upgrade process. Is that right? If I do not plan to upgrade Discourse via the web UI, I guess I don’t need it…

Since you asked me specifically . . . sort-of, it’s where Rails gets its config. That’s not a very good answer, but it’s my best free answer. But we’re getting some really great free answers here, so maybe you’ll get a better one. :wink:

I don’t know, but there isn’t much reason to find out. Either it will work, or it will fail one day and you’ll have no reason why and no one else will either.

And, in my experience, it’ll happen during your Christmas holiday and one of your most important sites will be down for 18 hours until you finally give up and re-configure the site from scratch.