Skip to main content

Execute Commands and Access Shell in Containers

Execute a single command

Execute ps command to identify running processes in container kettle-popper-manager which is a part of service instance popcorn-controller-service-1 in application popcorn-controller running on gothenburg-bergakungen site.

supctl do --site gothenburg-bergakungen applications popcorn-controller \
service-instances popcorn-controller-service-1 containers kettle-popper-manager \
exec ps
PID USER TIME COMMAND
1 root 0:00 /sbin/docker-init -- /bin/sh -c $EXECUTABLE
7 root 0:00 kettle-popper-manager
36 root 0:00 ps

Execute an interactive command

Standard input is connected to command's standard input and pseudo-TTY is allocated. This allows to run interactive commands, like shell. This example executes sh in a container on a remote site.

supctl do --site gothenburg-bergakungen applications popcorn-controller \
service-instances popcorn-controller-service-1 \
containers kettle-popper-manager exec-interactive sh
/ $ ps
PID USER TIME COMMAND
1 root 0:00 /sbin/docker-init -- /bin/sh -c $EXECUTABLE
7 root 0:00 kettle-popper-manager
48 root 0:00 sh
54 root 0:00 ps
/ $ exit

Using the Web UI

You can also run an interactive exec session from the Web UI. Navigate to the application site and click overview and expand the application to see the container:

Exec from Overview

Or you can use the containers tab:

Exec from Containers

That will open a terminal session in your browser:

Exec interactive

If you use the "Open terminal tab" you will get a separate browser tab for the session.