4

I'm using a bash shell (Mingwg64) on windows, to run bash from a docker container.

Tobi@DESKTOP MINGW64 /
$ docker run -i debian bash
ls

gives the result: bash: line 1: $'ls\r': command not found which from what I can tell is because there's a \r prepended to the usual \n when I press the enter key - as I'm on windows.

Anyone know a good fix for this?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Tobi
  • 143
  • 3

1 Answers1

2

The documentation for docker run tells:

If you do not specify -a then Docker will attach to both stdout and stderr . You can specify to which of the three standard streams (STDIN, STDOUT, STDERR) you’d like to connect instead, as in:

$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash

For interactive processes (like a shell), you must use -i -t together in order to allocate a tty for the container process. -i -t is often written -it as you’ll see in later examples. Specifying -t is forbidden when the client is receiving its standard input from a pipe
[...]

So you should use -it instead of -i: the tty layer will have a chance to translate the terminal input from \r\n into \n for the target system:

$ docker run -it debian bash
A.B
  • 31,762
  • 2
  • 62
  • 101