Docker Community Forums

Share and learn in the Docker community.

Redirecting STDOUT

When i try exec:
ping > file
ping process write to file continuously (saves line by line),

When a I try the same in docker:

docker run --name tt --rm -d mongo bash -c “/bin/ping > /tmp/pingi”

the file /tmp/pingi is filled by 4096 kb portions

Is this normal behavior ?

regards, Olaf

It is depend on image ?
under image debian everything looks like ok

If you mean 4096-byte (4 KiB) chunks, yes, that seems pretty normal. (Writes to stdout and elsewhere can be buffered by the underlying library, and the default can be either “buffer up to the next newline” or “buffer in larger chunks” depending on whether stdout is a tty or not.)

I can think of a couple of differences between images (many are based on the Alpine distribution, which has a different libc; the specific ping(1) binary may or may not call setvbuf(3) or fflush(3)). Of course, suggests all of the MongoDB images are Debian-based, so…?


Thank you for complete explanation,

I want to redirect both stdout and stderr of a process to a single file. How do I do that in Bash bluestacks?