groot@galaxy:/var/discourse$ sudo ./launcher run app whoami
If a site is up and running the above command would not enter that site and start bash to run the command whoami but start up a new container based on the last bootstrapped image and then run the command.
In other words if I wanted to use launcher to learn about a live site running in a container I should use launcher enter instead of launcher run.
… to enter the running container and the check on status (or perform tasks) in the running container.
However, keep in mind this you can do “as you seem to want to do” using docker directly (and easily). There is no need to use an intermediate shell script to get this information in a running container:
# docker exec -it app whoami
root
You may find this link useful on the syntax of the docker exec command.
# docker exec -it app du -sh /shared/uploads
2.0M /shared/uploads
# docker exec -it app ls -l /var/www/discourse/plugins/
total 36
drwxr-xr-x 1 discourse discourse 4096 Jun 7 04:49 discourse-details
drwxr-xr-x 1 discourse discourse 4096 Jun 7 04:49 discourse-local-dates
drwxr-xr-x 1 discourse discourse 4096 Jun 7 04:49 discourse-narrative-bot
drwxr-xr-x 1 discourse discourse 4096 Jun 7 04:49 discourse-presence
drwxr-xr-x 1 discourse discourse 4096 Jun 7 04:49 discourse-unsupported-browser
drwxr-xr-x 12 discourse root 4096 Jun 7 04:49 docker_manager
drwxr-xr-x 1 discourse discourse 4096 Jun 7 04:49 lazy-yt
drwxr-xr-x 11 discourse root 4096 Jun 7 04:49 neo-revive-discourse
drwxr-xr-x 1 discourse discourse 4096 Jun 7 04:49 poll
root@localhost:/var/discourse# docker exec -it app ls -l /shared
total 112
drwxr-xr-x 3 discourse www-data 4096 May 23 09:57 backups
drwxr-xr-x 10 root root 4096 Jun 7 04:55 letsencrypt
drwxr-xr-x 4 root root 4096 May 23 09:43 log
drwxr-xr-x 2 postgres postgres 4096 May 23 09:43 postgres_backup
drwx------ 19 postgres postgres 4096 Jun 7 04:57 postgres_data
drwxrwxr-x 3 postgres postgres 4096 Jun 7 04:57 postgres_run
drwxr-xr-x 2 redis redis 4096 Jun 8 02:56 redis_data
drwxr-xr-x 2 root root 4096 May 28 04:19 ssl
drwxr-xr-x 4 root root 4096 May 23 09:52 state
drwxrwxrwx 4 discourse www-data 4096 Jun 7 04:57 tmp
drwxr-xr-x 3 discourse www-data 4096 May 23 09:46 uploads
Hopefully, these fun examples give you some ideas on how to enjoy using docker exec to “learn about a live site running in a container”, as you asked about @EricGT
Here are a few more examples for fun:
# docker exec -it app ls -l /shared/tmp/redis.sock
srwxrwxrwx 1 redis redis 0 Jun 7 04:57 /shared/tmp/redis.sock
This one is not necessary because the unix socket is in the shared volume, but you get the idea:
#docker exec -it app redis-cli -s /shared/tmp/redis.sock monitor
OK
(truncated, tons of live, streaming data)
and finally, of course, our favorite “old maid” of sys admin commands:
That was an awesome reply and am I very grateful for the reply which gave me some insight into how other Docker system admins think about what is important and quickly get a look at that info, however Docker commands are an old friend of mine and what I really just wanted was a simple yes or no answer to
Did I get this right. launcher run does not use a current running container?
I spent a few hours the other day analyzing a bash trace of the launcher run command and was wanting to make sure my analysis was right. I would not have expected launcher run to start up an entirely new container just to run a single command like whoami. What is more scary is that if one thinks the command will work against the current running container and give them feedback about the container running the live site, instead it will be giving information back about a different container.
I fully agree that the way you are doing it with the Docker commands is the way I would be doing it, but I also would agree that unless you know the difference between $ and # that you shoud stay very far away from the Docker commands and put your trust in launcher.
Now that I know you like using questions with an auxiliary question as a pretext to shout-out about things the you find awesome, I will try and surreptitiously add them from time to time.
Yes, I use docker run as well (however, not launcher run) ; but I have not really found a reason to run docker run and append a shell command after the run command, because as mentioned in my reply, I always use docker exec.
Sorry you found my reply about why I use docker exec a “pretext to shout-out about things”. I assure you, I am really busy on many projects and don’t need pretexts to shout-out things and was only trying to help you accomplish your task because I don’t use launcher run to run shell commands in a Discourse container, I only use docker exec as mentioned in my reply; trying to help you.
Good luck with your future Discourse sys admin tasks!
The reason I am asking specifically about launch run is that I am creating an SOP manual for some other Discourse admins as we are exploring the possibility of self-hosting and I needed to understand each launcher command in detail to document it. Right now the SOP notes that using launcher run will create a new container so warns not to use launcher run.
I believe that you are right that ./launcher run cranks up a new container and runs the command there. If you want to run the command in the existing container you need to do it with docker as discussed.
If ./launcher didn’t behave this way then it couldn’t work if there wasn’t an existing container.