Create process in linux namespaces
Project description
# pyspaces
Works with Linux namespaces througth glibc with pure python
## Goals
There is so many beautiful tools like [docker](https://github.com/docker/docker), [rocket](https://github.com/coreos/rkt) and [vagga](https://github.com/tailhook/vagga) written on go and rust, but no one on python.
I think that is because there is no easy way to works wit linux namespaces on python:
* you can use [asylum](https://pypi.python.org/pypi/asylum/0.4.1) - project that looks like dead and with codebase hosted not on mainstream hub like github
* or you can use [python-libvirt](https://pypi.python.org/pypi/libvirt-python/1.2.13) bindings with big layer of abstraction
* or just use native glibc library with ctypes
* otherwise subprocess.Popen your choice
I want to change it: i want to create native python bindings to glibc with interface of python multiprocessing.Process.
## Example
First simple example
```python
from pyspaces import Container
def execute(argv):
os.execvp(argv[0], argv)
cmd = "mount -t proc proc /proc; ps ax"
c = Container(target=execute, args=(('bash', '-c', cmd),),
uid_map='0 1000 1',
newpid=True, newuser=True, newns=True
)
c.start()
print("PID of child created by clone() is %ld\n" % c.pid)
c.join()
print("Child returned: pid %s, status %s" % (c.pid, c.exitcode))
```
```bash
PID of child created by clone() is 15978
PID TTY STAT TIME COMMAND
1 pts/19 S+ 0:00 bash -c mount -t proc proc /proc; ps ax
3 pts/19 R+ 0:00 ps ax
Child returned: pid 15978, status 0
```
CLI
```bash
space -v execute --pid --fs --user --uid '0 1000 1' bash
```
Works with Linux namespaces througth glibc with pure python
## Goals
There is so many beautiful tools like [docker](https://github.com/docker/docker), [rocket](https://github.com/coreos/rkt) and [vagga](https://github.com/tailhook/vagga) written on go and rust, but no one on python.
I think that is because there is no easy way to works wit linux namespaces on python:
* you can use [asylum](https://pypi.python.org/pypi/asylum/0.4.1) - project that looks like dead and with codebase hosted not on mainstream hub like github
* or you can use [python-libvirt](https://pypi.python.org/pypi/libvirt-python/1.2.13) bindings with big layer of abstraction
* or just use native glibc library with ctypes
* otherwise subprocess.Popen your choice
I want to change it: i want to create native python bindings to glibc with interface of python multiprocessing.Process.
## Example
First simple example
```python
from pyspaces import Container
def execute(argv):
os.execvp(argv[0], argv)
cmd = "mount -t proc proc /proc; ps ax"
c = Container(target=execute, args=(('bash', '-c', cmd),),
uid_map='0 1000 1',
newpid=True, newuser=True, newns=True
)
c.start()
print("PID of child created by clone() is %ld\n" % c.pid)
c.join()
print("Child returned: pid %s, status %s" % (c.pid, c.exitcode))
```
```bash
PID of child created by clone() is 15978
PID TTY STAT TIME COMMAND
1 pts/19 S+ 0:00 bash -c mount -t proc proc /proc; ps ax
3 pts/19 R+ 0:00 ps ax
Child returned: pid 15978, status 0
```
CLI
```bash
space -v execute --pid --fs --user --uid '0 1000 1' bash
```
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
pyspaces-1.1.tar.gz
(6.0 kB
view details)
File details
Details for the file pyspaces-1.1.tar.gz
.
File metadata
- Download URL: pyspaces-1.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4e33a8c33fad059253542f5c82b7de342047cd814e06e9d4356586b457d0f8e |
|
MD5 | efdf793fb6ed6a37dd7c73c1f83eb24b |
|
BLAKE2b-256 | c37f194603570d2caa7debf71eb60f9bd61c40b851a0500a385b1a18f78e4d35 |