0

I need access to data (logs and cached files) from my docker containers, and so I am following instructions in this article on bindmounting volumes.

https://www.digitalocean.com/community/tutorials/how-to-share-data-between-the-docker-container-and-the-host

I have created the ~/appdata/example-app/logs directory on the server and started a container with the following command.

$ docker run -d -v ~/appdata/example-app/logs:/logs --restart always -p 81:80 path-to-docker-image-repo

But no logs are being output to the server directory.

I run the following command to inspect the files within the container:

$ docker exec -t -i example-app /bin/bash

I can see that my log file does indeed exist in the container (and have also verified that the app is running as expected). Note that this app is an ASP.NET Core app. I'm not sure if that is relevant, possibly because the path structure may be different for ASP.NET core apps?

logs\2019-06-14.log.json

I don't understand why I'm not seeing the files in the ~/appdata/example-app/logs directory.

Also, I actually want two directories mounted to the server, an additional directroy for cached images as well as logs, if this is possible?

gbro3n
  • 6,729
  • 9
  • 59
  • 100
  • try just "appdata/example-app/logs:/logs (removed ~/) – Abhishek D K Jun 14 '19 at 08:29
  • Could it be that docker daemon is not allowed to write to this directory? Can you try changing the ownership or access rights of the logs folder on your host machine just to check? I've witnessed weird behaviour from docker when it comes to mounting volumes without proper permissions – Kārlis Ābele Jun 14 '19 at 08:35
  • Abhishek DK - I tried your suggestion but it did not work – gbro3n Jun 14 '19 at 14:06
  • Kārlis Ābele - do you know how you would go about changing the changing the ownership or access rights for the docker daemon? Thanks – gbro3n Jun 14 '19 at 14:06
  • I have also reviewed this document https://stackoverflow.com/questions/23439126/how-to-mount-a-host-directory-in-a-docker-container, where there is reference to using absolute paths, but this has not worked and is in conflict with the documentation also. – gbro3n Jun 14 '19 at 14:31

1 Answers1

0

Instead of ~/appdata/example-app/logs, try using $PWD/appdata/example-app/logs

Mornor
  • 3,471
  • 8
  • 31
  • 69