Issue
My OS is Windows. When creating a Docker container and interacting with it using Windows powershell:
docker create -i --name test_container debian
docker container start -i test_container
And running a command such as ls
, then it gives the following error:
bash: line 2: $'ls\r': command not found
I assume this is because newlines in windows (\r\n
) are different than unix (\n
).
How can I use powershell interactively with Docker?
I've searched online for a solution on this, but only get results on converting files, not working with powershell directly. I've also looked through the settings of Docker to see if there's an option on this, but am unable to find anything to change this behavior. Running docker start --help
does not provide any special options for usage with powershell.
I specifically want to use powershell as I dislike cmd and the shell provided by Docker (the up/down keys don't work as expected for example).
Solution
I only now realized that I should pass the pseudo-tty option (-t
) when creating the container.
The following runs without issue:
docker create -it --name test_container debian
docker container start -i test_container
The problem is thus solved.
Answered By - user20664576 Answer Checked By - Katrina (WPSolving Volunteer)