Giter Site home page Giter Site logo

marcotessarotto / diyc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from w-vi/diyc

0.0 1.0 0.0 24.88 MB

A simple educational linux container runtime.

Home Page: http://wvi.cz/diyC/

License: GNU General Public License v2.0

Makefile 6.73% C 89.43% Dockerfile 3.85%

diyc's Introduction

diyC modified for a vm host using Linux Kernel 4.4.74 (without CLONE_NEWPID and CLONE_NEWUTS support) and running a container based on Ubuntu 18.04 with python3.8, pip3 and a specific list of python packages

A simple educational Linux container runtime.

It is intentionally simple and leaves a lot of stuff out. It is a single C file of roughly 500 lines including comments showing the core features of the Linux used to build containers. It includes also the creation of a container from an image to clarify how images and containers are related.

Modified to run on a vm with Linux Kernel 4.4.74

this fork is used on a virtual machine which has a 4.4.74 Linux Kernel configured without CLONE_NEWPID and CLONE_NEWUTS.

Also included in this repo is Dockerfile for exporting an ubuntu 18.04 file system with support for python3.8 and pip3

Python3 packages

modify Dockerfile if you need additional python3 packages (using pip)

Download minimal Ubuntu 18.04 image

docker build .

// lookup id of docker image just created (image_id)

docker image ls

// run container from image:

docker run -it <image_id>

// lookup id of container just created (container_id)

docker ps -a

docker export <container_id> > ubuntu1804.tar

gzip ubuntu1804.tar

installation and first run

make setup

make

mkdir images/ubuntu

tar -xcf ubuntu1804.tar.gz -C images/ubuntu/

./diyc my1 ubuntu /bin/bash

pip3 list

Documentation

http://wvi.cz/diyC/ or pure markdown in the docs directory.

Prerequisites

This is a educational piece of software and has not been tested on many systems, here are the prerequisites:

  • recent Linux kernel supporting needed namespaces and cgroups
  • overlayfs
  • ip tool (iproute2 package)
  • iptables
  • gcc
  • make
  • bash

Apart from overlayfs most of the distros are prepared and ready, if not please consult your distro package manager. Overlayfs is in the mainline kernel so it should be straightforward.

Note: Kernel needs to be configured to support following namespaces PID, mount, network and UTS, cgroups are needed as well. Most of the GNU/Linux distros have this support enabled by default.

Installation

  1. make setup

It creates the necessary directory structure as well as prepares the networking part like iptables rules, bridge (diyc0) and so on. To remove the networking bits like bridge and iptables rules run make net-clean which removes them all.

  1. make

Builds the runtime.

  1. Done

It also builds a nsexec which executes a local command in namespaces. See nsexec --help to see what namespaces are available. Usage is very simple sudo ./nsexec -pnu myhost bash will start a new bash in new pid, network and UTS namespace.

diyc's People

Contributors

marcotessarotto avatar redtree0 avatar w-vi avatar

Watchers

 avatar

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.