How to connect to a container on a server managed by Kamal and run an interactive session?
Interactive server actions
Kamal comes with a kamal server exec
to execute a single command on the server. If we pass the -i
option, we’ll start the interactive session that doesn’t cancel the connection immediatelly.
Similarly, Docker comes with docker exec
command with the -it
options to run a container process interactively.
If we combine both of these we’ll get what we need. A single command to run something interactively out of a single container:
$ kamal server exec -i "docker exec -it [CONTAINER] [COMMAND]"
Example
Here’s an example with kamal-proxy:
$ kamal server exec -i "docker exec -it kamal-proxy bash"
After running the comment we’ll be dropped into the container running Kamal Proxy.
Then we can play with the proxy without running long commands:
$ kamal-proxy stop app-web --message=""
$ kamal-proxy resume app-web
Check out my book
Learn how to use Kamal to deploy your web applications with Kamal Handbook. Visualize Kamal's concepts, understand Kamal's configuration, and deploy practical life examples.