Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs to generate a unique ID for Docker #2

Closed
wants to merge 1 commit into from

Conversation

juanbretti
Copy link
Contributor

One way to generate a unique ID on a Docker, is to get the first ethernet MAC address.
Here is more information: https://stackoverflow.com/a/48651560/3780957.
The MAC address is stored in this file: cat /sys/class/net/eth0/address

One way to generate a unique ID on a **Docker**, is to get the *first* ethernet MAC address.
Here is more information: https://stackoverflow.com/a/48651560/3780957.
The MAC address is stored in this file: `cat /sys/class/net/eth0/address`
@ezekg
Copy link
Member

ezekg commented Dec 31, 2022

A MAC address is not a constant value. It can change depending on many factors, such as ISP or simply your current network device (wired vs WiFi), so I don’t think it should be relied upon.

@ezekg ezekg closed this Dec 31, 2022
@juanbretti
Copy link
Contributor Author

Thank you @ezekg for your feedback.
I agree with you that MAC Addresses are not constant values.

Notice the idea of using the MAC Address is third in the case of Linux systems. It is proposed as fail-safe.

All the previously used values, for example /etc/machine-id could be changed as well. For example StackOverFlow
As you mentioned, similar could happen with the proposed ethernet address /sys/class/net/eth0/address, here StackOverFlow

But I think a solution should be found for Dockers.
Maybe pulling the container ID from the running container?

@ezekg
Copy link
Member

ezekg commented Jan 27, 2023

Hey @juanbretti, sorry for the late response. There's some discussion on Docker containers here. That discussion talks about using cgroup to obtain a unique container ID. The big problem with using a MAC address is that it can change randomly (ISP, WiFi/wired, etc.), without any explicit action from the end user.

Feel free to open another PR that does something with cgroup within a Docker container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants