I just wanted to post a quick step by step for anyone else struggling with this who needs a bit more detailed guidance.
Steps to make this work:
SSH to your server where you have Discourse running.
Change directory to
Enter the docker container running Discourse:
./launcher enter app. If you have called your container something else, replace
app with the name of your container.
Change to the discourse user (inside the container):
su - discourse.
Navigate to the discourse directory inside the container:
Run your command, for example:
RAILS_ENV=production bundle exec script/discourse export_category 1
If you follow all of these steps to the letter then it should work for you. I was initially getting confused as to where I should be the discourse user in what directory.
Copying from container to host
By default the file you generate will be stored in the container itself. To copy from the container to the host (your server running the container) run the following:
docker cp <container-id>:<path-to-file-on-container> <path-to-copy-to-on-host>
You will need to replace everything inside of
<> with real values. To obtain your container id run
My command looked like this:
docker cp a72e14c978ae:/var/www/discourse/category-export-2016-07-25-144953.json /tmp