{"id":37206479,"url":"https://github.com/friz-zy/pyspaces","last_synced_at":"2026-01-14T23:46:07.126Z","repository":{"id":30258668,"uuid":"33810029","full_name":"Friz-zy/pyspaces","owner":"Friz-zy","description":"Works with Linux namespaces througth glibc with pure python","archived":true,"fork":false,"pushed_at":"2018-03-05T17:21:40.000Z","size":88,"stargazers_count":88,"open_issues_count":2,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-27T07:41:06.592Z","etag":null,"topics":["containers","glibc","linux-namespaces","python"],"latest_commit_sha":null,"homepage":null,"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/Friz-zy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"security.md","support":null}},"created_at":"2015-04-12T08:59:23.000Z","updated_at":"2025-05-23T21:36:55.000Z","dependencies_parsed_at":"2022-08-07T15:01:33.545Z","dependency_job_id":null,"html_url":"https://github.com/Friz-zy/pyspaces","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/Friz-zy/pyspaces","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friz-zy%2Fpyspaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friz-zy%2Fpyspaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friz-zy%2Fpyspaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friz-zy%2Fpyspaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Friz-zy","download_url":"https://codeload.github.com/Friz-zy/pyspaces/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Friz-zy%2Fpyspaces/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28439537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["containers","glibc","linux-namespaces","python"],"created_at":"2026-01-14T23:46:06.406Z","updated_at":"2026-01-14T23:46:07.118Z","avatar_url":"https://github.com/Friz-zy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyspaces\nWorks with Linux namespaces through glibc with pure python\n\n[![License](https://pypip.in/license/pyspaces/badge.svg)](https://pypi.python.org/pypi/pyspaces/)\n[![Latest Version](https://pypip.in/version/pyspaces/badge.svg)](https://pypi.python.org/pypi/pyspaces/)\n[![Downloads](https://pypip.in/download/pyspaces/badge.svg)](https://pypi.python.org/pypi/pyspaces/)\n[![Docs](https://readthedocs.org/projects/pyspaces/badge/)](https://pyspaces.readthedocs.org/en/latest/)\n\ndiscuss: [reddit](https://www.reddit.com/r/Python/comments/33z84l/linux_namespaces_througth_glibc_with_pure_python/), [habrahabr](http://habrahabr.ru/company/wargaming/blog/256647/)\n\n## Goals\n\nThere 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 in go and rust, but none in python.\nI think that is because there is no easy way to work with linux namespaces in python:\n\n* you can use [asylum](https://pypi.python.org/pypi/asylum/0.4.1) - a project that looks dead and with a codebase hosted not on mainstream hub like github\n* or you can use the [python-libvirt](https://pypi.python.org/pypi/libvirt-python/1.2.13) bindings with a big layer of abstraction\n* or just use the native glibc library with ctypes\n* otherwise subprocess.Popen -- your choice\n\nI want to change this: I want to create native python bindings to glibc with interface of python multiprocessing.Process.\n\nPS: you can look at [python-nsenter](https://github.com/zalando/python-nsenter) too, it's looks awesome.\n\nPPS: new project from author of asylum - [butter](https://pypi.python.org/pypi/butter/0.10)\n\n## Example\n\nFirst simple example:\n```python\nimport os\nfrom pyspaces import Container\n\n\ndef execute(argv):\n    os.execvp(argv[0], argv)\n\ncmd = \"mount -t proc proc /proc; ps ax\"\nc = Container(target=execute, args=(('bash', '-c', cmd),),\n              uid_map='0 1000 1',\n              newpid=True, newuser=True, newns=True\n              )\nc.start()\nprint(\"PID of child created by clone() is %ld\\n\" % c.pid)\nc.join()\nprint(\"Child returned: pid %s, status %s\" % (c.pid, c.exitcode))\n```\noutput:\n```bash\nPID of child created by clone() is 15978\n\nPID TTY      STAT   TIME COMMAND\n1   pts/19   S+     0:00 bash -c mount -t proc proc /proc; ps ax\n3   pts/19   R+     0:00 ps ax\n\nChild returned: pid 15978, status 0\n```\n\n## CLI\n\n```bash\nspace execute -v --pid --mnt --user --uid 1000 --gid 1000 bash -c 'mount -t proc /proc; ps ax'\n```\n\n```bash\nspace chroot --pid --uid '0 1000 1' ~/.local/share/lxc/ubuntu/rootfs/ /bin/ls /home/\n```\n\n```bash\nspace inject --net --mnt 19840 bash\n```\n\nNote: If the program you're trying to exec is dynamically linked, and the dynamic linker is not present in /lib in the chroot environment - you will get the following error: \"OSError: [Errno 2] No such file or directory\". You need all the other files the dynamic-linked program depends on, including shared libraries and any essential configuration/tables/etc in the new root directories. [src](http://www.ciiycode.com/0JiJzPgggqPg/why-doesnt-exec-work-after-chroot)\n\n## Security\n\nRead [this article](https://github.com/Friz-zy/awesome-linux-containers#security) please\n\n## Changelog\n[on github](https://github.com/Friz-zy/pyspaces/blob/master/CHANGELOG.md)  \n[digest](https://allmychanges.com/p/python/pyspaces/)  \n\n## TODO\n\n- [x] namespaces: clone \u0026 Container\n- [x] CLI\n- [x] Chroot\n- [x] setns \u0026 inject\n- [ ] cgroups\n- [ ] SCM: apparmor \u0026 selinux\n- [ ] capabilities\n- [ ] mount\n- [ ] network\n- [ ] move CLI to separate package\n- [ ] addons\n- [ ] container list\n- [ ] support for lxc, vagga, rocket, docker, etc...\n- [ ] ...\n- [ ] one tool for rule them all!!1\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriz-zy%2Fpyspaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriz-zy%2Fpyspaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriz-zy%2Fpyspaces/lists"}