2

I want to run a shell script which calculates the free disc space on the host machine so that the docker container can use the information in one of its REST endpoints.

Is there a clean way to do this or should I try to solve the problem differently. Because I'm quite sure that it is not a good idea to create this coupling between host and container.

Linde_98
  • 418
  • 4
  • 10
  • 1
    How often would you want to recalculate the disk space? if its only every 10 minutes or so, I would use a cronjob on the host machine that puts the data into a file in a directory that the container can reach. – DownloadPizza Nov 13 '20 at 09:34
  • I would like to run the calculation whenever a file is uploaded. But when its hard to trigger the calculation from inside the container a scheduled task with cron job sounds like a good idea. 10 Minutes would be an appropriate duration. – Linde_98 Nov 13 '20 at 09:40
  • 1
    Actually I have a better idea, give me a few minutes to write an answer – DownloadPizza Nov 13 '20 at 09:53
  • 1
    Welp, it got closed. But the gist is: Have a directory with a file `size` and the uploads directory, make it accessible by both the container and the host. On the host: use `inotify` to watch for added files (doesnt work with nested directorys, so only finds `uploads/*` and not `uploads/aaa/*`, edit the file `size` with your new info everytime inotify yells at you. and just query the file from the rest API every time. – DownloadPizza Nov 13 '20 at 10:02

0 Answers0