Resource information

Dear All,

I’m creating an application by using the Python3.x, and also I’m dockerizing it. The main functionality of this app is to provide the information about CPU, RAM, Storage, Network, Power and other attached devices(i.e., printers or sensors/actuators info). During the docker image building procedure…I’m setting the ‘Privileged’ mode on…so that whenever I’ll install the app into a device then this app can able to fetch all the information about the host devices. But my question is that, can you please tell me that is there any way to get the host device info as well as container’s info at a time?? Can you please guide me that how can I fetch that info for the container and also for the host device…Thanking you in advance.

Regards,
Souvik

You actively don’t want an isolation/virtualization layer like what Docker provides. Run this service directly on the host.

(You probably could bypass Docker isolating the host’s network interfaces and devices from you…but if you did all of that, you’d essentially wind up with a process running as root on the host that happens to have its own filesystem space, and there are easier ways to get something like that than packaging it in Docker and then trying hard to escape Docker space. A Python virtual environment is a much better match.)

Dear David,

Thank you so much for your response and concern. I agree with you but after dockerizing my application I’m easily getting the host device information by setting up the privileged mode on during the docker image building procedure. But David, without setting the privileged mode on…I can get the container information also…But I want to get the container info as well as the host device info in a single process…I mean at a time…is the bypassing methodology will help me to get this two info?

Thanking you in advance.

Regards,
Souvik

I’m not totally sure I understand the question. If you’re trying to get an exhaustive list of hardware details you pretty much need to run as root on the host. At that point, if you wanted to inspect other containers, /var/run/docker.sock would be available to you and you could make normal Docker API calls (or use the docker-py module). If you were introspecting your own process, you can get some stats from /proc/self and there’s a little bit of information available from the Python runtime.

For the application you describe, if it was run in a Docker container, I’m not sure any details of the container itself would be interesting. The container’s network environment, for instance, is totally artificial, boring (there’s a single fixed interface), and not really useful to outside observers (the Docker-assigned IP address is unreachable from any other host and is in a reserved IPv4 address space).

Dear David,

Thank you so much for your concern and help…and sorry for creating the confusion. Well as you said…I think that would be another way to get the container info as well the host device info…I really appreciate your help…thank you so much dear :slight_smile: