kamal icon indicating copy to clipboard operation
kamal copied to clipboard

piping into `kamal exec` does not work

Open prullmann opened this issue 8 months ago • 1 comments

When trying to pipe data into commands executed in containers using kamal exec, no data is recieved.

Use Case:

I am trying to restore a database backup via the following command from my dev machine: kamal accessory exec -i --reuse mysql 'mysql example_db"' < example_db_backup.sql (ignoring password handling for this example)

Kamal translates this to: ssh -t example_host docker exec -it example_project-mysql 'mysql example_db' < example_db_backup.sql

However, to make piping through docker work, -i has to be set, but not -t.

Proposed Solution:

I suggest that besides the --interactive/-i flag, a --tty/-t flag is added to control both independently.

Alternative Solution: Kamal could also check if STDIN is attached to a file/pipe when interactive is enabled and set -i instead of -ti in this case.

If one of those solutions sound acceptable, I am happy to write a PR.

prullmann avatar Apr 09 '25 15:04 prullmann

For backword compatibility I think we should stick to -it by default. But I think using -i when attached to a file or pipe makes sense.

djmb avatar Apr 21 '25 14:04 djmb

Was fixed by https://github.com/basecamp/kamal/pull/1544

djmb avatar Nov 07 '25 10:11 djmb