I need to log in to a bash console within a docker container, which runs in a remote host.
The following commands work:
(local)$ ssh -i myKey user@remoteHost
(remote)$ docker exec -it myContainer /bin/bash
Note that I use passwordless authentication with SSH. My scenario is a bit more involved, including a script to get into a single command (which would actually also figure out docker container ID), this is enough to show the problem. When I try to run in a single command, I get the following error:
(local)$ ssh -i myKey user@remoteHost "docker exec -it myContainer /bin/bash"
cannot enable tty mode on non tty input
How can I run this SSH and get past the "cannot enable tty" error?
Use the -t
option (twice) with ssh
:
ssh -tt -i myKey user@remoteHost docker exec -it myContainer /bin/bash
you can use the command (from your pc) docker-machine
with this you are able to connect to the docker server (if the api are exposed) an manage the docker like your local environment (docker ps, docker run etc etc)
documentation:
https://docs.docker.com/machine/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With