I want to create a docker image which will run a command similar with tail, how can I redirect the output of this command in the logs of the container?
CodePudding user response:
Everything you output to stdout or stderr will be part of the docker container logs by default.
So for example while this container is running
docker run --rm --name busy busybox sh -c "while true; do echo 'to stdout'; echo 'to stderr' >&2; sleep 1; done"
... you can inspect its logs:
docker logs -f busy
So in short: Just use your tail -f
normally.