When you want to start an interactive program using TTY on a remote server with the following command:
docker run --rm -it <image-name> /bin/sh
you can do so without any issues by first executing:
ssh <user>@<remote-server>
and then, once the remote shell is initiated, running:
docker run --rm -it <image-name> /bin/sh
This allows you to use the TTY-based program on Docker without any problems.
However, if you attempt to run both SSH and the Docker run command in one go from your local machine (e.g., Mac), like this:
ssh <user>@<remote-server> -- docker run --rm -it <image-name> /bin/sh
you will encounter an error:
ssh docker run the input device is not a TTY
In such cases, you can resolve the issue by adding the -t
option to the ssh
command.
ssh -t <user>@<remote-server> -- docker run --rm -it <image-name> /bin/sh
And that’s it!
Comments