Code Monkey home page Code Monkey logo

containers-from-scratch's Introduction

Containers from scratch

In this video from DockerCon 2017, Liz Rice demonstrates how to implement a container-like thing in a few lines of Go code. I've attempted the same thing, but using Ruby instead of Go.

Note that I worked on this project as a way of learning about containers and hence my approach may be foolish and the code may contain mistakes. Re-use at your own risk!

Requirements

  • Ruby
  • Vagrant
  • Virtual Box (or another suitable provider)

Setting up the VM

vbhost$ vagrant up # may take some time

Running the container on the VM

vbhost$ vagrant ssh
ubuntu@ubuntu-xenial:~$ sudo su - root
root@ubuntu-xenial:~# cd /vagrant
root@ubuntu-xenial:/vagrant# ./container run /bin/bash
run: Running ["/bin/bash"] as PID 15742
child: Running ["/bin/bash"] as PID 15744
grandchild: Running ["/bin/bash"] as PID 1
root@container:/# ps
  PID TTY          TIME CMD
    1 ?        00:00:00 ruby
    4 ?        00:00:00 bash
   11 ?        00:00:00 ps
root@container:/# exit
exit
root@ubuntu-xenial:/vagrant#

See Liz's talk and my commit notes for examples of things to explore in the container.

Limitations

This has only been tested on Ubuntu 16.04.3 and given that it relies heavily on making native system calls, it's likely not to work on other versions of Linux.

Credits

Many thanks to Liz Rice for the inspiration of her talk and for making her source code publicly available.

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.