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 logs <container id> | grep <some value> doesn't work #9508

Closed
billumina opened this issue Dec 4, 2014 · 6 comments
Closed

docker logs <container id> | grep <some value> doesn't work #9508

billumina opened this issue Dec 4, 2014 · 6 comments

Comments

@billumina
Copy link

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

@LK4D4
Copy link
Contributor

LK4D4 commented Dec 4, 2014

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

@simonavril
Copy link

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

@cpuguy83
Copy link
Member

@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

@simonavril
Copy link

@cpuguy83 Thanks a lot for that.

@lucasavila
Copy link

lucasavila commented Nov 8, 2016

try docker logs -f --tail 0 container

@goatwu1993
Copy link

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

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

8 participants