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

Add an id for Docker containers #3

Merged
merged 4 commits into from
Feb 1, 2023
Merged

Commits on Jan 27, 2023

  1. 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.
    juanbretti authored Jan 27, 2023
    Configuration menu
    Copy the full SHA
    14e376b View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2023

  1. Included "if 'docker' in mountinfo" for "linux"

    Following your review, I made some updates on the patch.
    juanbretti authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    7b12ce3 View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2023

  1. 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`
    juanbretti authored Jan 31, 2023
    Configuration menu
    Copy the full SHA
    53a5807 View commit details
    Browse the repository at this point in the history

Commits on Feb 1, 2023

  1. 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).
    juanbretti authored Feb 1, 2023
    Configuration menu
    Copy the full SHA
    5ffae30 View commit details
    Browse the repository at this point in the history