How do I open the Rails console in Discourse Docker in production mode?

Run rails c instead - this will open the console as the correct user in the correct mode.

You can also do this with rake and discourse (for /var/www/discourse/script/discourse).