Reputation: 2567
Trying to execute shell commands in the docker container from localhost and inside the container ,
docker exec -i <container-id> sh -c "ls -l"
also tried docker exec -ti <container-id> sh -c "ls -l"
it lists the output and keeps on hanging in the terminal .
Executed the above command by login in to the container
It lists the output and when i type exit
command , it starts hanging
Server Free RAM : 3GB
docker logs --details <container-id>
returns empty output
Upvotes: 13
Views: 13448
Reputation: 102
Kind of similar happened for me too. Was using Phpstorm terminal and it hanged. Restarted server - nothing. Only complete reboot of phpstorm helped...
Upvotes: 0
Reputation: 305
Had the same issue. I was passing a step-by-step docker tutorial. Was using Visual Studio 2022. In step-by-step tutorial worked fine.
When I tried myself docker exec command hanged.
The reason of the issue was that I used built in Visual Studio package manager console. But for running docker commands one should specifically start powershell console from the context menu of the solution.
For details you can visit this link
Upvotes: 1
Reputation: 3436
You need to allocate a pseudo-TTY with the -t
option along with interactive or -i
option. Try this:
$ docker exec -ti <container-id> sh -c "ls -l"
Upvotes: 19