Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active July 31, 2018 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YumaInaura/aacc80bda81a35306ef2dad2469fe1bb to your computer and use it in GitHub Desktop.
Save YumaInaura/aacc80bda81a35306ef2dad2469fe1bb to your computer and use it in GitHub Desktop.
Docker —Using docker run with interactive mode but without tty ( What happens? )

Docker — Using docker run with interactive mode but without tty ( What happens? )

Usually we into docker container with docker run command option like -it. But if not specified -t, what happens?

In the first place, what is tty?

$ docker run --help | grep tty
  -t, --tty                            Allocate a pseudo-TTY

Umm i don’t understand that enough, yet.

Pseudoterminal - Wikipedia

Trying

docker run --interactive alpine

No PRONPT mark

At first, you will find, console has no PRONPT mark. ( e.g # $ ) Console freezing? No you are already in the docker container's control.

Control arrow keys

You can not handle arrow keys well.

^[[C^[[C^[[C
/bin/sh:    : not found

In this case, it seems execute commands as control character ( But probably terminal does not output them ).

Execute commands

But you can execute commands without --tty.

echo

echo Alice
Alice
echo Bob
Bob

ls

ls var/lib

apk
misc
udhcpd

exit

exit

Conclusion

On docker interactive mode without tty device, you can execute commands, but it does not behave well as terminal.

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment