{"id":15007476,"url":"https://github.com/zalando/python-nsenter","last_synced_at":"2025-10-03T15:30:18.374Z","repository":{"id":20769262,"uuid":"24053999","full_name":"zalando/python-nsenter","owner":"zalando","description":"Enter kernel namespaces from Python","archived":true,"fork":false,"pushed_at":"2020-03-27T16:18:56.000Z","size":30,"stargazers_count":141,"open_issues_count":5,"forks_count":20,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-09-17T01:19:36.730Z","etag":null,"topics":["docker","linux-kernel","namespaces","nsenter","python"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/nsenter","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zalando.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-15T11:35:23.000Z","updated_at":"2025-08-23T18:13:07.000Z","dependencies_parsed_at":"2022-08-21T20:01:11.336Z","dependency_job_id":null,"html_url":"https://github.com/zalando/python-nsenter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zalando/python-nsenter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando%2Fpython-nsenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando%2Fpython-nsenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando%2Fpython-nsenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando%2Fpython-nsenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalando","download_url":"https://codeload.github.com/zalando/python-nsenter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando%2Fpython-nsenter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277417642,"owners_count":25814529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","linux-kernel","namespaces","nsenter","python"],"created_at":"2024-09-24T19:10:14.946Z","updated_at":"2025-10-03T15:30:18.100Z","avatar_url":"https://github.com/zalando.png","language":"Python","readme":"=======\nNSEnter\n=======\n\n.. image:: https://travis-ci.org/zalando/python-nsenter.svg?branch=master\n   :target: https://travis-ci.org/zalando/python-nsenter\n   :alt: Travis CI build status\n\n**NSEnter** is a Python package that enables you to enter Linux kernel namespaces — mount, IPC, net, PID, user and UTS — with a single, simple \"setns\" syscall. The command line interface is similar to the nsenter_ C program.\n\nProject Origins\n---------------\n\nWhen working with Docker_ containers, questions usually arise about how to connect into a running container without starting an explicit SSH daemon (`which is considered a bad idea`_). One way is to use Linux Kernel namespaces, which Docker uses to restrict the view from within containers. \n\nThe ``util-linux`` package provides the ``nsenter`` command line utility, but `Ubuntu 16.04 LTS`_ unfortunately does not. Jérôme Petazzoni provides a `Docker recipe`_ for ``nsenter`` on GitHub, or you can compile ``nsenter`` `from source`_. As there is only one simple syscall to enter a namespace, we can do the call directly from within Python using the ``ctypes`` module. We bundled this syscall to create NSEnter.\n\nAdditional Links\n````````````````\n- \"Entering Kernel Namespaces from Python,\" Zalando Tech `blog post`_\n- On PyPi_\n\nRequirements\n````````````\n- Python 2.6 or higher\n\nInstallation\n````````````\nFrom PyPI::\n\n    sudo pip3 install nsenter\n\nFrom git source::\n\n    python3 setup.py install\n\nUsage\n`````\nExample of command line usage::\n\n    docker run -d --name=redis -t redis\n    sudo nsenter --all --target=`docker inspect --format '{{ .State.Pid }}' redis` /bin/bash\n\n\nExample of usage from Python:\n\n.. code:: python\n\n    import subprocess\n    from nsenter import Namespace\n\n    with Namespace(mypid, 'net'):\n        # output network interfaces as seen from within the mypid's net NS:\n        subprocess.check_output(['ip', 'a'])\n\n    # or enter an arbitrary namespace:\n    with Namespace('/var/run/netns/foo', 'net'):\n        # output network interfaces as seen from within the net NS \"foo\":\n        subprocess.check_output(['ip', 'a'])\n\nDevelopment Status\n``````````````````\nThis project works as-is. There are currently no plans to extend it, but if you have an idea please submit an Issue to the maintainers.\n\nLicense\n-------\nSee file_.\n\n.. _Docker: https://www.docker.com/\n.. _which is considered a bad idea: https://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/\n.. _Ubuntu 16.04 LTS: https://askubuntu.com/questions/439056/why-there-is-no-nsenter-in-util-linux\n.. _Docker recipe: https://github.com/jpetazzo/nsenter\n.. _from source: https://askubuntu.com/questions/439056/why-there-is-no-nsenter-in-util-linux\n.. _nsenter: http://man7.org/linux/man-pages/man1/nsenter.1.html\n.. _blog post: http://tech.zalando.com/posts/entering-kernel-namespaces-with-python.html\n.. _PyPi: https://pypi.python.org/pypi/nsenter\n.. _file: https://github.com/zalando/python-nsenter/blob/master/LICENSE\n","funding_links":[],"categories":["Partial Access"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalando%2Fpython-nsenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalando%2Fpython-nsenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalando%2Fpython-nsenter/lists"}