Where are Docker logs stored by default?


wayner

18 posts in this topic Last Reply

Recommended Posts

I created a semi-manual docker for the Harmony-api using this file.  It works fine and when I click on the Docker from the unRAID UI I can see the log.  But I can't figure out what file the log is actually stored in.  Should it be in /var/log?  I don't see anything there. 

 

I am concerned that this log will grow to be very large as it is constantly polling the Logitech Harmony hubs on my LAN.  It seems that it will grow to at least a few hundred kB per day.  Is there any way to have the log flush every day or X number of bytes?

Link to post

Ok - I think I have found this.  It is in the painfully named 

/var/lib/docker/containers/123456789074329872398471204271304723094872307234/ folder where the last parameter is the Container ID.  Is that correct?  And why use the Container ID rather than the docker name?  That makes it a pain to find the correct docker.

 

How do I limit the size of the log file?  Or is this best done from within the application?

Link to post
Ok - I think I have found this.  It is in the painfully named 
/var/lib/docker/containers/123456789074329872398471204271304723094872307234/ folder where the last parameter is the Container ID.  Is that correct?  And why use the Container ID rather than the docker name?  That makes it a pain to find the correct docker.
 
How do I limit the size of the log file?  Or is this best done from within the application?
https://forums.lime-technology.com/topic/57181-real-docker-faq/?tab=comments#comment-564326

Sent from my SM-T560NU using Tapatalk

Link to post
  • 8 months later...

Is it possible to add a share in the logs folder so i can copy the log file to windows PC ? 

I need to send a complete log file to a vendor (google) but I cant figure out how to copy the whole log to a windows PC.

 

Link to post
4 hours ago, jj_uk said:

Is it possible to add a share in the logs folder so i can copy the log file to windows PC ? 

I need to send a complete log file to a vendor (google) but I cant figure out how to copy the whole log to a windows PC.

 

Not sure about creating a share, but you should be able to use the Config File Editor plugin to open the log file in your browser and just copy/paste to a text file.

Link to post
On 6/20/2018 at 11:30 PM, Squid said:

 


docker logs nameOfContainer > /boot/containerLog.txt

 

Thanks.

 

I run this command:

docker logs google-music-uploader > /boot/containerLog.txt

and the log scrolls up the screen, the file "containerLog.txt" is created but it's empty.

Edited by jj_uk
Link to post
55 minutes ago, jj_uk said:

 

Thanks.

 

I run this command:


docker logs google-music-uploader > /boot/containerLog.txt

and the log scrolls up the screen, the file "containerLog.txt" is created but it's empty.

 

Sounds like the log data is emitted to standard error instead out standard out - then you will see the text scroll on the screen while a zero-size file is created.

 

Output emitted to standard error can be redirected with the following - the number 2 represents the stderr output stream.

cmd 2> file

Link to post
31 minutes ago, jj_uk said:

Yes, this worked. Any ideas why its going to the error stream instead of the file stream? (unRAID version 6.5.3)

 

 

Docker captures both stdout and stderr output.

 

https://docs.docker.com/config/containers/logging/

 

For information about redirection, see the following link:

https://askubuntu.com/questions/625224/how-to-redirect-stderr-to-a-file

 

But > redirects stdout.

And 2> redirects stderr.

And &> redirects both.

Or you can do: cmd > outfile 2>&1

 

Link to post
  • 2 years later...
On 6/21/2018 at 12:30 AM, Squid said:

 


docker logs nameOfContainer > /boot/containerLog.txt

I tried to capture logs but I have an error :

root@Sparta:~# docker logs deconz > /mnt/user/Downloads/containerLog.txt
/usr/bin/xauth:  file /root/.Xauthority does not exist
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
QObject::connect: Cannot queue arguments of type 'QTextBlock'
(Make sure 'QTextBlock' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QTextCursor'
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)

 

Link to post

Are you sure that's not the output from the docker logs command?  

 

It's kinda weird the way the command works because it outputs to stderr the errors in the logs.   You need to add 2>&1 to the command to also send the errors to the file

Link to post

Thank, is there another way to get the logs? I had to enable the debugging options of a container for a developer and there are so many lines per second that Firefox crashes before I had time to copy logs (I need to collect around 5 mins of logs).

Edited by Alex.b
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.