I started some docker containers with:
docker-compose up -d
(here the docker-compose.yml)
and then:
docker-compose logs -f web
but if I write on another shell:
docker-compose exec web echo "hello" >> /dev/stdout
Nothing appear in the live logs screen. Same for any other container. Why? Am I doing something wrong?
/dev/stdout is different for each process. Your docker-compose logs will only show you the output of your PID 1 process, not other processes that run in that container namespace.
Update: also note:
>> /dev/stdout will be applying to docker compose exec web echo "hello" on the host .. not to echo "hello" inside the container>> /dev/stdout is kind of a no-op because a process will write to stdout by default .. and, for stdout, >> (append) is the same as > (redirect) because there's no pre-existing output that can be overwritten/replaced.Solved putting this inside the virtualhost configuration:
CustomLog /proc/self/fd/1 combined
ErrorLog /proc/self/fd/2
So, in order to show up logs on docker, you can use /proc/self/fd/1 and /proc/self/fd/2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With