In a Support discussion tagged docker, jarrett reports that after installing Discourse via Docker using an IP address as hostname, switching to a domain name left old IP addresses appearing in outgoing emails — despite updating DISCOURSE_HOSTNAME in /var/discourse/containers/app.yml and hostname in /var/www/discourse/config/discourse.conf, and running ./launcher restart app and SiteSetting.refresh!. Although Discourse.base_url in the Rails console shows the correct domain, emails still use the old IP. ZeroFlux suggests rebuilding the container with ./launcher rebuild app, which Moter8 and ZeroFlux confirm preserves the database. jarrett expresses concern about data loss, but others reassure him backups are optional. Eric_Toombs questions whether a rebuild is truly necessary, citing a meta.discourse.org post suggesting restart suffices for env changes — and reports success without rebuild. sam clarifies that environment changes require destroying and restarting the container (via ./launcher destroy app && ./launcher start app), though rebuild is the recommended catch-all to avoid confusion — albeit with slightly more downtime. The consensus leans toward rebuild as the safest, most reliable fix, though some users report success with just restart.
I installed Discourse with Docker per the official instructions.
At the time of installation, I didn’t have a domain name ready, so I just used an IP address as the hostname. Later, I got the domain name working, and Discourse is accessible via that hostname.
However, the IP address–which is no longer the correct hostname for this installation–still shows up in various places. One such place is outgoing emails. When a user receives a notification of a new post, the link back to the topic has the IP address as the hostname.
I’ve replaced the IP address where I could find it:
In the host OS at /var/discourse/containers/app.yml, the DISCOURSE_HOSTNAME key.
Inside the Docker container at /var/www/discourse/config/discourse.conf, the hostname key.
I tried SiteSetting.refresh! from the Rails console. I also tried restarting the Docker container with ./launcher restart app.
I see that in app/views/email/_post.html.erb, the links go to Discourse.base_url. From the Rails console, I see that Discourse.base_url is correct:
root@discourse:/var/www/discourse# rails console production
irb(main):001:0> Discourse.base_url
=> "http://myhost.example.com"
Yet the outgoing emails still have the IP address instead of the correct hostname. Any idea why that would happen, and how it might be fixed?
I think rebuilding the container will resolve your issue. Double-check the hostname details in the app.yml and make sure they’re saved to your liking. Then rebuild Discourse’s container, which destroys the old one, bootstraps a new one, and starts it up.
Fear not, the database is preserved through rebuilds. The only things that
could be “lost” are items mentioned in the app.yml. In this case, that
includes your old IP address! Also, if you ever want to install new
plugins, that process will also require app rebuilds.