Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dokku - where is my application's directory

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.

like image 476
Max Yari Avatar asked May 05 '15 17:05

Max Yari


2 Answers

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:

  1. 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
    
  2. 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.

  3. 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.

like image 54
helmbert Avatar answered Sep 20 '22 03:09

helmbert


@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.

like image 37
Felix Avatar answered Sep 20 '22 03:09

Felix