0

I'm trying to login into container using following command.

docker exec -t -i $(docker container ps -f "name=mycontainer" -q) sh

It works well in Ubuntu and isn't working in Windows 10.

3
  • You have to explicitly specify that Windows is host. In Windows there is no $(...) function, so you need to get your container name in other ways. Why not simply write mycontainer ?
    – grapes
    Jan 18, 2019 at 9:57
  • @grapes in cmd you are correct, but powershell supports it stackoverflow.com/questions/26984637/…
    – secustor
    Jan 18, 2019 at 10:02
  • @secustor good to know, thank you!
    – grapes
    Jan 18, 2019 at 10:16

2 Answers 2

1

On my windows machine, it only works when I supply the /bin/bash to the command.

Here is the working command:

docker exec -it mongodb /bin/bash
0

You have to remove the " to work.

docker exec -ti $(docker container ps -f name=mycontainername -q) sh

But why would you this anyway? You can run:
docker exec -ti mycontainername sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.