Giter VIP home page Giter VIP logo

cfs-rs's Introduction

containers from scratch - in rust

Minimal re-implementation of lizrice/containers-from-scratch in Rust.

why?

Liz Rice gave several fantastic talks at DockerCon and other events named Containers from Scratch. In these talks, she impressively live-codes a minimal container runtime in about 100 lines of Golang.

Many important container tools such as docker/engine, opencontainers/runc, etc are written in Golang. Golang is a great tool for building and running containers and I love the language. However, safely handling syscalls in the language can sometimes be tricky. Rust offers a safe, memory-efficient and memory-safe wrapper around the syscall C-bindings and enforces strict error handling. Due to these safety improvements, I believe Rust is a good choice to reimplement Liz Rice's cfs example. Also, I'm trying to find any excuse to write Rust!

In this repository, I've attempted to write a very minimal container runtime, based Liz Rice's original Golang implementation.

Note: I'm pretty new to Rust and this is not idiomatic code. If you have any suggestions, please send a PR or ping me on Discord!

Credit:

usage

This will only work on a Unix system. I developed in WSL2.

# build the Docker container
make build

# run a shell
make run

# run args in the mini-container!
cfs args...

examples

How do you know this is working?

example 0: new hostname

# run hostname in the Docker container
root@e8f49cd2ff70:/home# hostname
e8f49cd2ff70

# run hostname in the cfs container: we've changed hostnames
root@e8f49cd2ff70:/home# cfs run hostname
cfs-container

example 1: isolated process view

# run ps in the container
root@cb3e7658f63f:/usr/src/cfs# ps
  PID TTY          TIME CMD
    1 pts/0    00:00:00 sh
    7 pts/0    00:00:00 bash
    8 pts/0    00:00:00 ps

# run ps in cfs: the container thinks cfs is PID 1
root@cb3e7658f63f:/home# cfs run ps
  PID TTY          TIME CMD
    1 ?        00:00:00 cfs
    2 ?        00:00:00 ps

example 2: restricted view of mounts (still need to fill in output)

# run mount in the container
root@cb3e7658f63f:/home# cfs run mount

cfs-rs's People

Contributors

camerondurham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cfs-rs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.