running command inside container
-
wrote on Oct 27, 2022, 9:21 AM last edited by girish Oct 27, 2022, 8:26 PM
for an import script I want to run a bash command inside a (here: nextcloud..) container. This instruction to identify the container from the hostname doesn't seem to work anymore:
https://forum.cloudron.io/post/2011
what's the current approach?
-
The script mentioned in the other forum post should still work fine. At its core is the following docker cli line to detect the container id:
docker ps -q -f label=fqdn=$app -f label=isSubcontainer=false
The attributes it filters on have not changed since then.
-
for an import script I want to run a bash command inside a (here: nextcloud..) container. This instruction to identify the container from the hostname doesn't seem to work anymore:
https://forum.cloudron.io/post/2011
what's the current approach?
Hi @perler
from the settings of the app on in the Cloudron dashboard you could open a terminal. which will give you access to the container.
You could also use the cloudron cli from your workstation.
cloudron exec --app $locationofyournextcloud
. -
wrote on Oct 27, 2022, 10:54 AM last edited by
we want to use this in a script which runs locally on the cloudron server - what would be the preferred way here?
-
we want to use this in a script which runs locally on the cloudron server - what would be the preferred way here?
-
wrote on Oct 27, 2022, 11:32 AM last edited by
it's a one off thing, but preferrable within a script (so it should resolve the local container-id by hostname)
-
The script mentioned in the other forum post should still work fine. At its core is the following docker cli line to detect the container id:
docker ps -q -f label=fqdn=$app -f label=isSubcontainer=false
The attributes it filters on have not changed since then.
-
-
it's a one off thing, but preferrable within a script (so it should resolve the local container-id by hostname)
@perler Have you seen https://docs.cloudron.io/apps/#cron already? This will run the job in the context of a container.
I am happy to add other "meta" patterns, if none of those fit your use case
-