Skip to content

Direct the log to a specific file/directory #313

Closed Answered by Eirikr70
Eirikr70 asked this question in Q&A
Discussion options

You must be logged in to vote

So, I have solved the problem by

  • copying the log file to an Docker-external path with a Systemd service,
  • setting up a filter and a jail in Fail2ban.

I leave here the code that I set up in that aim, in case someone would be interested. I welcome any constructive comments.
The executable file for the Systemd service

eric@odroid:~/startup$ cat copie-log-searxng.sh
#!/bin/bash

readonly CONTAINER='searxng'

readonly DEST_FILE='/srv/nas/logs/searxng/searxng.log'

echo $$ > /home/eric/startup/pid_copie_log

ERROR=0

while ERROR==0 ; do :

  read -r LOG_FILE < <(docker inspect --format '{{.LogPath}}' "${CONTAINER}")

  tail -Fn 1 "${LOG_FILE}" >> "${DEST_FILE}"

  ERROR=$?

done

The service u…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Eirikr70
Comment options

@Eirikr70
Comment options

Answer selected by return42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant