-1

I have a python Flask app running in a docker container, along with several other apps and an nginx reverse proxy. Some of the other apps write log files to volumes mounted from the host. Some of these apps are not well behaved, and sometimes use up all of the available disk space. I would like my app to report back the result of a "df" command run on the docker host. What would be the best way to do this?

Running

subprocess.getoutput('df')

only shows the df from the docker container, not from the host machine.

J21042
  • 1,214
  • 4
  • 19
  • 33

2 Answers2

3

You can do this, but it's usually a bad idea and requires one or more workarounds. Some ways to do this that come to mind:

  • Have the host periodically write the information you need (e.g. the output of df) to a file that is mounted by the container.
  • Expose some sort of web service on the host that the container can reach (this screams of security issues)

You might want to look at limiting the size of the volumes that the container write to. This answer has additional information on that.

RQDQ
  • 15,461
  • 2
  • 32
  • 59
-1

You cannot do this. This is against the container idea. For monitoring host use host scripts.

Miq
  • 3,931
  • 2
  • 18
  • 32