Host identification in Docker container

Viewed 60

PROBLEM:

My application consists of one server and two clients which can be run on Windows, Linux, MAC operating systems. My goal is for the server to be able to determine if the clients are running on the same physical host or different ones. When clients work outside of a container, this can be done easily (for example, using a /etc/machine-id). The problem arises when containers come into play. The same /etc/machine-id is no longer unique across containers.

RESTRICTIONS:

The environment of docker containers cannot be changed (that is, it is not possible to use environment variables or volumes)

QUESTION:

Is there a way, maybe OS-specific or not, to identify a host that is independent of whether containerization is used or not?

1 Answers

SOLUTION:

I used the host boot time to identify the host. Windows, Linux and MAC provide ways to get this information. These methods return the boot time of the host when called from a container. This is not a completely accurate solution to my problem, since there is some possibility that the hosts were running at the same time, but this probability is small enough to be neglected.

Related