docker logging fundamentals . Also using syslog as a non default example.
213
New to containers? This video might help.
Imagine somelegacyapp is 20+ years old binary, but now your salary provider wants its output to go to the container log.
You put the said binary in the image, using e.g alpine:latest in your Dockerfile, build it and then start the container, for example like this
docker run -itd --name mycontainername imagename
Then you go to the just started container shell and this is how you do it:
# linux redirection jamboree
# redirect both STDOUT and STDERR to the container log
./somelegacyapp &>/dev/console
# redirect only the STDOUT to the container log
./somelegacyapp 1>/dev/console
# redirect only the STDERR to the container log
./somelegacyapp 2>/dev/console
And then emboldened and invigorated you might try to write streams 1 (STDOUT) and 2 (STDERR) to log.txt and then redirect the log.txt to the container log, and then run the whole as a daemon!
./somelegacyapp &>log.txt>/dev/console &
Note: it is important not to insert spaces above!
Generally, peek around a few simple sources in the /dbj folder of this Alpine build.
Content type
Image
Digest
sha256:e851fa69b…
Size
3.2 MB
Last updated
over 3 years ago
docker pull dbjdbj/dbjsyslog