Docker Community Forums

Share and learn in the Docker community.

Docker run, docker exec and docker logs


(Pepipho) #1

Hi!
When I do this:
docker run --name test -d busybox sh -c "while true; do $(echo date); sleep 1; done"
and then
docker logs
I get logs, but when I do first run and then docker exec:
docker run --name test -it busybox
and
docker exec -d test sh -c "while true; do $(echo date); sleep 1; done"
and
docker start test
docker logs -f test
I don’t get nothing.
Why this happens? What is solution for executing commands in running container and to get logs?


(Rdxmb) #2

Why this happens?

Because with -it you run a terminal inside the container with interactive , so STDOUT and STDERR are the terminal and not the logs.