0

When i create a container group with 2 desired instances with a command containing the volume specification as follows:

> ... -v log_vol:/opt/ibm/logs --env
> LOG_LOCATIONS=/opt/ibm/logs/messages.log,/opt/ibm/logs/debug.log,/opt/ibm/logs/trace.log
> -e TRACE_LEVEL=*~info -e MAX_LOG_FILES=5 -e MAX_LOG_FILE_SIZE=20 ...

In this case each individual running-container-instance of the group will have a similar directory /opt/ibm/logs/ to store logs.

When the application within the individual container instance generates logs, the log data is lost as it is mounted to a shared volume called log_vol. The logs get replaced on every new entry.

  • Can someone suggest me on how to handle it?
  • Are there any ways that we can attach a volume specification post container instance creation?
krckumar
  • 544
  • 4
  • 21

1 Answers1

2

In this case, it's best to think of the volume as something similar to a shared network drive, with the separate containers running on different hosts. If the processes are assuming they're the only one writing to the file, and caching/overwriting on each write, this will be the result.

Perhaps instead have the containers/programs write to something like /opt/ibm/logs/messages.$HOSTNAME.log so that the assumption they own their own logfile is correct? Or similarly, have the container create for itself /opt/ibm/logs/$HOSTNAME/ on boot, and then write to messages/debug/trace.log under there?

Wtower
  • 18,848
  • 11
  • 103
  • 80
N Fritze
  • 431
  • 3
  • 9