Moby: docker logs <container id> | grep <some value> doesn't work

Created on 4 Dec 2014  路  6Comments  路  Source: moby/moby

docker logs -f doesn't cut it with a busy log file. :)

arelogging

Most helpful comment

@simonavril This is because your log entry is for stderr, piping works with stdout.
instead do

docker logs 2>&1 | grep hello
# OR
docker logs 2>/dev/null | grep hello

All 6 comments

@billumina I will appreciate if you'd provide simple example, because for me grep is working

Docker logs is not working how I would expect and a google search brought me to this ticket. Here's what is happening

savril@savril-laptop:~/workspace/$ docker logs grave_newton  
mkdir: cannot create directory '/var/www/foo/application/config': File exists
savril@savril-laptop:~/workspace/$ docker logs grave_newton | grep hello
mkdir: cannot create directory '/var/www/foo/application/config': File exists
savril@savril-laptop:~/workspace/$ docker -v
Docker version 1.4.1, build 5bc2ff8

@simonavril This is because your log entry is for stderr, piping works with stdout.
instead do

docker logs 2>&1 | grep hello
# OR
docker logs 2>/dev/null | grep hello

@cpuguy83 Thanks a lot for that.

try docker logs -f --tail 0 container

try docker logs -f --tail 0 container

Why so many thumbs down?

docker logs -f container_id 2>&1 | grep "something"

This does not work on my app.

docker logs -f --tail 0 container_id 2>&1 | grep "something"

This DOES work

Was this page helpful?
0 / 5 - 0 ratings