Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker: Store logs on a different volume outside of the container #450

Open
jonalange opened this issue Apr 18, 2024 · 1 comment
Open
Assignees

Comments

@jonalange
Copy link

I'm pretty new to docker, so this might be the root of the problem.

When I run docker run --rm gilleslamiral/imapsync imapsync <usual imapsync arguments> the logs are created somewhere inside the container. And if I understand that correctly, they will be removed after imapsync is done, because the container is stopped.

No matter if this is true or not I would like to store the logs on a volume outside of the container.

I tried this: docker run --rm -v /var/services/homes/backup:LOG_imapsync gilleslamiral/imapsync imapsync <usual imapsync arguments> but that doesn't seem to work. Either my volume path is wrong (but I don't think so, because I can access it with the same user as I run the container with cd /var/services/homes/backup gets me exactly where I want the logs to be. So I assume that LOG_imapsync is wrong. What path should I put there so the logs get correctly stored where I want them.

When I try to use ./LOG_imapsync as stated as the correct log path, I get an error that I have to use absolute paths.

Any idea? Thanks!

@gilleslamiral
Copy link
Member

gilleslamiral commented Apr 18, 2024

When I run docker run --rm gilleslamiral/imapsync imapsync <usual imapsync arguments> the logs are created somewhere inside the container

Yes, in the directory /var/tmp/uid_65534/LOG_imapsync/

What path should I put there so the logs get correctly stored where I want them?

Add the option --log

Here is a working example, just tested:

mkdir /var/tmp/kk
chown nobody  /var/tmp/kk
docker run -v /var/tmp/kk:/var/tmp/uid_65534/LOG_imapsync  gilleslamiral/imapsync imapsync --log --testslive
ls -l  /var/tmp/kk/*
/var/tmp/kk/2024_04_18_12_26_11_447_test1_test2.txt

Another solution, no volume needed, just a classical Unix redirection:

docker run  gilleslamiral/imapsync imapsync --testslive | tee /tmp/imapsync_log.txt
cat /tmp/imapsync_log.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants