-
Notifications
You must be signed in to change notification settings - Fork 144
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
Machineid can be edited not unique in docker container #10
Comments
I would suggest that we use cgroup to determine that we run under docker and than use the hash like string in cgroup as a salt. Unique literal for docker container: /proc/self/cgroup
Try different docker images
Output: |
Usual Linux images for Docker containers, does not have the originally listed files. Following the conversation at denisbrodbeck/machineid#10, I am including the following: Because `/proc/self/cgroup` seams to not be working on same Docker versions, I am also including `/proc/self/mountinfo`. Tested on `Python 3.11` running on `Debian GNU/Linux 11 (bullseye)` inside a Docker.
Looks like the Take a look at:
Another idea is to extract the Here is a PR with this proposal: keygen-sh/py-machineid#3 |
* Add an id for Docker containers Usual Linux images for Docker containers, does not have the originally listed files. Following the conversation at denisbrodbeck/machineid#10, I am including the following: Because `/proc/self/cgroup` seams to not be working on same Docker versions, I am also including `/proc/self/mountinfo`. Tested on `Python 3.11` running on `Debian GNU/Linux 11 (bullseye)` inside a Docker. * Included "if 'docker' in mountinfo" for "linux" Following your review, I made some updates on the patch. * Update __init__.py * Fixed the indentation to 2. * Checked on a Docker container the `if 'docker' in cgroup:` works when the `docker` is not found. Same test with `mountinfo`. * When the full code does not find an ID raises the following: `Python 3.11.0 (main, Nov 15 2022, 19:58:01) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import machineid >>> print(machineid.id()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.11/site-packages/machineid/__init__.py", line 90, in id raise Exception('failed to obtain id on platform {}'.format(platform)) Exception: failed to obtain id on platform linux` * Update __init__.py Check if `cgroup` and `mountinfo` are not None, before checking if `docker` is inside the file. To not rise a possible error when is trying to check `if 'docker' in None` (when the file does not exist).
I want to use machineid in docker to make sure that machines are unique, but machineid file can be edited in docker.So it happens that docker containers in diffierent machines can have the same machineid.
The text was updated successfully, but these errors were encountered: