A quick example to illustrate how powerstrip-logfiles can be used to collect log files from inside an Nginx container.
Run powerstrip-logfiles and Powerstrip as described in the main project readme. Going forward this example assumes Powerstrip running and DOCKER_HOST to be set as follows:
$ export DOCKER_HOST=tcp://127.0.0.1:2375You can just run Nginx from a toy image off of Docker Hub based on the Dockerfile in this repository:
$ docker run -d --name nginx-example -p 80:80 raychaser/powerstrip-logfiles:latest-nginx-exampleOr, if you want to run an build locally:
$ docker build -t raychaser/nginx-example . && \
docker run -d --name nginx-example -p 80:80 raychaser/nginx-exampleHit http://localhost a couple of times, and maybe try to force some 404 errors by going to something like http://localhost/schnitzel.
You should be able to see the Nginx access and error logs in the container:
$ docker exec -it nginx-example ls -la /var/log/nginxAnd you should be able to see the contents of the access log:
$ docker exec -it nginx-example tail /var/log/nginx/access.logBefore the next step, shutdown and remove the Nginx contaienr:
$ docker stop nginx-example && docker rm nginx-exampleCreate another Nginx example container through powerstrip-logfiles with the Nginx log path specified on the commandline:
$ CID=$(DOCKER_HOST=localhost:2375 docker run -d --name nginx-example-powerstrip -p 80:80 -e LOGS=/var/log/nginx raychaser/powerstrip-logfiles:latest-nginx-example) && echo $CIDYou should now be able to see the Nginx container's /var under the host's /var/log/container-logfiles/containers/$CID/:
$ ls -la /var/log/container-logfiles/containers/$CID/And if you tail the access log from that location while hitting http://localhost you should see the hits being logged:
$ tail -F /var/log/container-logfiles/containers/$CID/var/log/nginx/access.logFinally, stop and remove the powerstrip Nginx example container:
$ docker stop nginx-example-powerstrip && docker rm nginx-example-powerstrip