Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

A lightweight pure-python container implementation

Project description

A lightweight pure-python container implementation.

It is a wrapper around the Linux namespace functionality through libc functions like unshare(), nsenter() and mount(). You can think of it as a sturdier chroot replacement, where cleanup is easy (no lingering processes or leaked mountpoints). It needs superuser privileges to run.



You can either install it with pip:

pip3 install furnace

Or if you want, the following commands will install the bleeding-edge version of furnace to your system.

git clone
cd furnace
python3 install

This will of course install it into a virtualenv, if you activate it beforehand.


The only dependencies are:

  • Python3.5+
  • Linux kernel 2.6.24+
  • A libc that implements setns() and nsenter() (that’s basically any libc released after 2007)


After installing, the main interface to use is the ContainerContext class. It is, as the name suggests, a context manager, and after entering, its run() and Popen() methods can be used exactly like subprocess’s similarly named methods:

from furnace.context import ContainerContext

with ContainerContext('/opt/ChrootMcChrootface') as container:['ps', 'aux'])

The above example will run ps in the new namespace. It should show two processes, furnace’s PID1, and the ps process itself. After leaving the context, furnace will kill all processes started inside, and destroy the namespaces created, including any mountpoints that were mounted inside (e.g. with['mount', '...'])).

Of course, all other arguments of run() and Popen() are supported:

import sys
import subprocess
from furnace.context import ContainerContext

with ContainerContext('/opt/ChrootMcChrootface') as container:
    ls_result =['ls', '/bin'], env={'LISTFLAGS': '-la'}, stdout=subprocess.PIPE, check=True)

    file_outside_container = open('the_magic_of_file_descriptors.gz', 'wb')
    process_1 = container.Popen(['cat', '/etc/passwd'], stdout=subprocess.PIPE)
    process_2 = container.Popen(['gzip'], stdin=process_1.stdout, stdout=file_outside_container)

As you can see, the processes started can inherit file descriptors from each other, or outside the container, and can also be managed from the python code outside the container, if you wish.

As a convenience feature, the context has an interactive_shell() method that takes you into bash shell inside the container. This is mostly useful for debugging:

import traceback
from furnace.context import ContainerContext

with ContainerContext('/opt/ChrootMcChrootface') as container:
    try:['systemctl', '--enable', 'nginx.service'])
    except Exception as e:
        print("OOOPS, an exception occured:")
        print("Entering debug shell")



We appreciate any feedback, so if you have problems, or even suggestions, don’t hesitate to open an issue. Of course, Pull Requests are extra-welcome, as long as tests pass, and the code is not much worse than all other existing code :)

Setting up a development environment

To set up a virtualenv with all the necessary tools for development, simply run

make dev

This will create a virtualenv in a directory named .venv. This virtualenv is used it for all other make targets, like check

Running tests

During and after development, you usually want to run both coding style checks, and integration tests:

make lint
make check

Please make sure at least these pass before submitting a PR.


This project is licensed under the GNU LGPLv2.1 License - see the LICENSE.txt for details

Project details

Download files

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

Files for furnace, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size furnace-0.0.5-py3-none-any.whl (23.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size furnace-0.0.5.tar.gz (23.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page