Coder Social home page Coder Social logo

trellixvulnteam / build-a-container-from-scratch_f7cx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ritika0991/build-a-container-from-scratch

0.0 0.0 0.0 234.22 MB

Shell 2.09% JavaScript 0.18% C++ 10.81% Python 35.76% Perl 16.69% C 23.20% Emacs Lisp 0.02% Clojure 0.01% Tcl 1.28% D 0.01% Go 0.02% Vala 0.01% Prolog 0.02% Awk 0.02% XSLT 0.01% XC 0.05% CSS 0.09% TeX 0.35% Makefile 0.19% HTML 9.20%

build-a-container-from-scratch_f7cx's Introduction

Build-a-container-from-scratch

Container is built using Linux namespaces and cgroups. Setup: If cgroup filesystem is not mounted, please first mount that. Then proceed with the given commands. You may need to get root privileges to execute these commands mkdir /sys/fs/cgroup/memory/demo_mem # This creates a cgroup named demo_mem
echo "104857600" > /sys/fs/cgroup/memory/demo_mem/memory.limit_in_bytes # We restrict this cgroup to only use 100 MB of memory
echo "0" > /sys/fs/cgroup/memory/demo_mem/memory.swappiness # Turns off memory swap.

To run the container,

gcc container.c

./a.out hostname veth-pair-num path-to-rootfs # You need to run this command with root privileges and is just a number which can be anything 2,3,4. sample usage is ./a.out jane 2 rootfs

If you want to run two containers then have separate copies of root file system and pass veth-pair argument at difference of 2. If you are using number 2 for one container, then you can't use 3 for other container. You should use only even numbers, i.e 2,4,6,etc and different for every container you want to fire.

It will spawn a shell that will run in separate network, mount, PID and UTS namespaces.

build-a-container-from-scratch_f7cx's People

Contributors

ritika0991 avatar trellixvulnteam 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.