Cannot use -lt when running Nginx Docker or cat logs

I recently pulled out a nginx image:

docker pull nginx 

I can run it successfully and go to http: // server_name and see the "Welcome to Nginx" page:

 docker run -d -p 80:80 nginx 

But when I try to check the logs:

 docker exec 6c79549e3eb4f6e5fc06f049b67814ac4560ce2cdd7cc6ae84b44b5ae09a9a05 cat /var/log/nginx/access.log 

It just hangs and displays nothing. Same thing with the error log. Now, if I create the test.txt file in the same folder and use docker exec to (view) the cat file, I execute without any freezes or any problems.

Even if I try to run it interactively, it just freezes:

 docker run -i -t -p 80:80 nginx 

Again, the terminal hangs on the next line, doing nothing, but it seems to work because I can access the nginx welcome page.

Actually, I got confused about what was going on, I tried to find this problem, but have not yet found a solution. Unable to view the logs, debugging them is quite difficult :) Also, do not move the access logs to stdout in the nginx container, because using the container of the agreement containers before entering standard output?

+7
docker nginx hang cat
source share
1 answer

If you go into the docker exec -it <container-id> /bin/bash and check the location of the ls -la /var/log/nginx/ , you will see the following output: lrwxrwxrwx 1 root root 11 Apr 30 23:05 access.log -> /dev/stdout lrwxrwxrwx 1 root root 11 Apr 30 23:05 error.log -> /dev/stderr Obviously, the logs are written to standard output. You can also try making cat access.log inside the container, and it still shows nothing.
Now the right way to get your logs goes beyond the container and makes docker logs <container-id> then you will see your logs. Hope this helps!

+11
source share

All Articles