1

I mounted my containers' logs to the host (e.g. /var/log/container1, etc). Now I want to use the host's logrotate.

But suppose I need to do this:

create 660 mysql mysql 

There is no mysql user/group on the host, so logrotate fails with:

unknown user 'mysql'

So I tried:

create 660 999 999 # 999 is mysql user's uid/gid within container 

But then I get:

unknown user '999'

So I tried:

create 660 999 999 su 999 999 

But that gives the same error.

How can I do this, without creating a dummy user on the host?

(BTW, before you tell me to rely on docker's own log rotation... this is just an example. I use various containers which do not log to stdout/stderr so I need to do log rotation myself.)

1 Answer 1

0

I think the problem is logrotate does not recognise a non-existent uid/gid, even though the filesystem does.

Workaround:

#create 660 mysql mysql # break it: will use default of root:root postrotate chown 999:999 /var/log/container1/ # fix it endscript 

This could lead to a race condition though.

If you have a better solution, please post it.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.