Skip to content
This repository was archived by the owner on Dec 5, 2022. It is now read-only.

Commit f8199bd

Browse files
committed
add Python usage example
1 parent 03f0aa6 commit f8199bd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@ Install from git source::
1515

1616
python3 setup.py install
1717

18-
Example usage::
18+
Example command line usage::
1919

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

23+
24+
Example usage from Python:
25+
26+
.. code::python
27+
28+
import subprocess
29+
from nsenter import Namespace
30+
31+
with Namespace(mypid, 'net'):
32+
# output network interfaces as seen from within the mypid's net NS:
33+
subprocess.check_output(['ip', 'a'])
34+
35+
2336
.. _nsenter: http://man7.org/linux/man-pages/man1/nsenter.1.html

0 commit comments

Comments
 (0)