alxndr alxndr - 2 years ago 231
Bash Question

Redirect several log files in docker container to stdout (legacy application)

I have to put legacy application into Docker container. The app is running fine but I cannot display all the log files. The problem is that the app is creating several log files (e.g.

service.log, license.log, security.log
etc.) AFTER starting the executable.

I have a starting script (let's call it
) which prepares some things (links, config) and then starts the app which creates the mentioned log files.

After some googling I have found similar problem and try to apply the solution that uses named pipes (creating link to
did not worked). So I placed the following in the starting script:

mkfifo /path/to/app/license.log && tail -f /path/to/app/license.log &
mkfifo /path/to/app/security.log && tail -f /path/to/app/security.log &

but the problem is that only FIRST file will be redirected to
docker logs
. The others are not visible at all.

The curious thing is that in
I have a line
which executes some specific commands depending on environment. Placing the
mkfifo license.log
in the
and the
mkfifo service.log
in the
The problem is that I have more files and do not want to
all of them.

Does anyone have an idea how to solve this?

Answer Source

Because it is a legacy application we still have to have the log files in place. In that case the solution that works for me is to create the files by touch and read them using tail:

touch /path/to/app/logfile.log && tail -f /path/to/app/logfile.log &

So replacing mkfifo with touch solved my problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download