Skip to main content

Enter kernel namespaces from Python

Project description

This Python package allows entering Linux kernel namespaces (mount, IPC, net, PID, user and UTS) by doing the “setns” syscall. The command line interface tries to be similar to the nsenter C program.

Requires Python 3.4.

See the introductory blog post “Entering Kernel Namespaces from Python”.

Install from PyPI:

sudo pip3 install nsenter

Install from git source:

python3 setup.py install

Example command line usage:

docker run -d --name=redis -t redis
sudo nsenter --all --target=`docker inspect --format '{{ .State.Pid }}' redis` /bin/bash

Example usage from Python:

import subprocess
from nsenter import Namespace

with Namespace(mypid, 'net'):
    # output network interfaces as seen from within the mypid's net NS:
    subprocess.check_output(['ip', 'a'])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nsenter-0.1.4-1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

nsenter-0.1.4_1-py3.4.egg (4.4 kB view details)

Uploaded Source

File details

Details for the file nsenter-0.1.4-1.tar.gz.

File metadata

  • Download URL: nsenter-0.1.4-1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nsenter-0.1.4-1.tar.gz
Algorithm Hash digest
SHA256 bd72b4cff7c58930d8b8bbedea34b944bc61d6beed3345b676963490f50405aa
MD5 d8b4875a6c782e164513c6e1b733215d
BLAKE2b-256 d3537901e92100a76b67d8a5f7e3d634cefd0c2f2c587df756028461b12a9d80

See more details on using hashes here.

File details

Details for the file nsenter-0.1.4_1-py3.4.egg.

File metadata

File hashes

Hashes for nsenter-0.1.4_1-py3.4.egg
Algorithm Hash digest
SHA256 6f88e3439e1108fc1fe6acbed5d9a5080a1c409d196dab890fbb2e20ba106bc5
MD5 a2ab66e137b0f7504f17c94005df9ad6
BLAKE2b-256 f089936c54e981a5161227767f30a7db6552447cf78e36cf5db676fe8f9ba3a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page