Skip to content

piping into kamal exec does not work #1485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
prullmann opened this issue Apr 9, 2025 · 1 comment
Open

piping into kamal exec does not work #1485

prullmann opened this issue Apr 9, 2025 · 1 comment

Comments

@prullmann
Copy link

prullmann commented Apr 9, 2025

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.

@djmb
Copy link
Collaborator

djmb commented Apr 21, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants