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 2.6 or higher
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'])
# or enter an arbitrary namespace:
with Namespace('/var/run/netns/foo', 'net'):
# output network interfaces as seen from within the net NS "foo":
subprocess.check_output(['ip', 'a'])
Project details
Release history Release notifications | RSS feed
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.2.tar.gz
(4.3 kB
view details)
Built Distribution
nsenter-0.2-py3-none-any.whl
(12.3 kB
view details)
File details
Details for the file nsenter-0.2.tar.gz
.
File metadata
- Download URL: nsenter-0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 876a18cb03de85948e4cd72fd4cfda4879561b7264f5722603f6437d452a25cb |
|
MD5 | a9e19cde39c93d91716f0be7dd0e14c5 |
|
BLAKE2b-256 | a5461bfe9cca7f2e12cb2d7d9082b14feb785bc63628fb795a34d53ef57a8b93 |
File details
Details for the file nsenter-0.2-py3-none-any.whl
.
File metadata
- Download URL: nsenter-0.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d44ba70199f9b454139f2093141e63218bca5b1285c65fcf6e4b139116088867 |
|
MD5 | d6806869b04c387913481d031553f122 |
|
BLAKE2b-256 | 8d6d65e257cd8cc42a68894292e28c8d25dcb5a6b8f959cfdd8c69cdc555efd1 |