Any commands hang terminal inside docker container.
I login in container with docker exec -t php-zts /bin/bash
And then print any elementary command (date, ls, cd /, etc.)
Command hang
When I press ctrl+c I going back to host machine.
But, if I run any command without container – it’s work normally
docker exec -t php-zts date
Wed Jan 26 00:04:38 UTC 2022
tty is enabled in docker-compose.yml
docker system prune and all cleanups can not help me.
I can’t identify the problem and smashed my brain. Please help 🙁
2
Answers
The solution is to use the flag
-i/--interactive
withdocker run
. Here is a relevant section of the documentation:You can try to run your container using -i for interactive and -t for tty which will allow you to navigate and execute commands inside the container
In the other hand you can run the container with docker run then execute commands inside that container like so:
tail -f /dev/null
will keep your container running.-d
will run the command in the background.