score: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

score:0

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

Related Query

More Query from same tag