I am trying to access logs of my Node.js
application which is written in file mylogfile.log
inside application's directory.
Using find / -type f -name mylogfile.log
i was able to see this output:
/var/lib/docker/aufs/diff/0303e86afdc58e13b5afcc07ea3694e0e9e6d5e5cf8530a0854a76fbe2baf574/app/mylogfile.log
/var/lib/docker/aufs/diff/a9a0dab44456acd8b43915ed686c282b778ab99df31f62076082e121274ef6e2/app/mylogfile.log
/var/lib/docker/aufs/mnt/0303e86afdc58e13b5afcc07ea3694e0e9e6d5e5cf8530a0854a76fbe2baf574/app/mylogfile.log
What are those directories (if this is a previous app pushes, why do i even need them, i don't really want to flood hard drive's space with them) and which of those is a directory of my currently running app?
Also inside ...mnt/
and ...diff/
there is much more folders with similar cryptic names.
Please note that the filesystem of a Docker container is not intended to be accessed by users from the host. It's quite complicated actually, since Docker uses a layered copy-on-write filesystem (like AUFS in your case, but that's distribution-specific; most Distros except Ubuntu use Devicemapper instead of AUFS, IIRC). What you see there are filesystem layers, each one containing the difference to one parent layer.
If you want to log stuff inside your application container, you should consider one of the following possibilities:
Put your log files into a volume. You can mount a host directory as a volume and write files in there. You need to specify mounts when creating the container, using the -v
flag (-v <host-directory>:<dir in container>
):
docker run -v /var/log/myapplication:/path/to/app/in/container myimage
Write your logs to stdout and let Docker worry about the logs. You can access the log (yes, it'll be just one big file) using
docker logs <container-name>
You'll also find the log file in your Docker runtime directory (usually /var/lib/docker
) in /var/lib/docker/containers/<container-id>/<container-id>-json.log
. This log file won't be rotated automatically however, so it might grow big.
Use an external logging service to write log data to another location in your network. Typical candidates would be syslog (old-school) or setting up something like Logstash or Graylog.
@helmberts answer is great and gives you all you need, I try to give a tiny bit of salt to the dish (and something dokku- not docker-specific).
The point is, your app lives in a restorable on-off environment. With your deployment (git push
) you kind of set up the ancester, everytime you start your app afterwords, you create a clone that dies once you stop the container (kind of).
You can do dokku run myapp ls /
to see how it looks like.
You could make changes (dokku run myapp touch /mytouched.file
) but these are not persisted (dokku run
gives you a fresh clone!) and "lost" immediately. If you want to have files somewhere forever, use a volume and mount it into you app-container(s). There is a cool plugin (dokku-volume) for that.
I cant tell you how to delete old diffs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With