Say I have a container that has everything I need to run my web application (such as https://github.com/grigio/docker-stringer for example). How would I go about inspecting the logs for the different services (web server, application server, database server)? With all of the tutorials so far I have only been able to view the logs for the specific command run when starting the container.
Asked
Active
Viewed 3,480 times
1 Answers
4
One method would be to configure your logs to write to stdout
and to use docker logs
to retrieve them.
Another option would be to use a bindmount
and link to your host file system.

Nick Stinemates
- 41,511
- 21
- 59
- 60
-
I can see using stdout if there was only one source of logs that I was interested, but if more than one service is running in the container that approach won't work. I see some discussion of VOLUMES on the docker wiki https://github.com/dotcloud/docker/wiki/Volumes-&-persistent-data-storage which I think is similar to your bindmount suggestion and word work well in my opinion. – Jon-Erik Jul 26 '13 at 19:16
-
1Yes. Volumes allow data to be shared across containers. Bindmounts allow you to tell the host/container to share the same directory. `docker run -v ./logs:/logs image` would mount the local (host) ./logs directory accessible by the container in /logs. – Nick Stinemates Jul 27 '13 at 02:32
-
Great! This looks exactly like what I was looking for. Thank you for your answer! – Jon-Erik Jul 27 '13 at 13:15
-
You'd have an example or a link to some, for your first method, the one about configuring the logs to write to `stdout` ? – Stephane Sep 06 '16 at 16:20
-
@NickStinemates how do you go about permissions to the mounted volume? When I did what you suggest, the mounted `/logs` folder inside the container is created with the owner and group `root`, while my application in the container runs with the user `daemon`. Consequently, my app cannot write to the `/logs` folder. Any ideas? – Szymon Przedwojski Jun 22 '17 at 12:50
-
In case anybody has the same issue as myself, I just found the answer [here](https://stackoverflow.com/a/29251160/1972469). Basically you need to set the user and group id (uid:gid) on the host folder the same as the uid:gid of the user running the application in docker. – Szymon Przedwojski Jun 22 '17 at 13:11