GithubHelp home page GithubHelp logo

tiny-docker's Introduction

tiny-docker: the essence of docker in 100 lines of C++

To evaluate the filesystem segregation feature of this tiny-docker, you will initially need an additional ubuntu filesystem for tiny-docker execution and mounting activities. You can arrange this using your existing ubuntu with the subsequent instructions:

sudo tar -cpf ubuntu-fs.tar --exclude=/home --one-file-system /
mv ubuntu-fs.tar /parent/directory/of/tiny-docker
cd /parent/directory/of/tiny-docker
mkdir ubuntu-fs
mv ubuntu-fs.tar ubuntu-fs
cd ubuntu-fs
sudo tar xf ubuntu-fs.tar

As I usually perform all the commands within my $HOME directory, ubuntu-fs.tar is also omitted by the --exclude=/home choice. If you don't execute these commands within your $HOME, you can manually specify ubuntu-fs.tar.

Following the prior setup, now you possess an ubuntu-fs directory located in the parent path of tiny-docker. You can now test it as follows:

make 
sudo make run

The output will appear as:

./mocker run /bin/bash
Parent running /bin/bash as 40000
Child running /bin/bash as 1
root@container:/# 

This indicates that hostname is separate. Furthermore, a ps aux will show:

root@container:/# ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0  10916  4016 ?        S    21:31   0:00 /bin/bash
root          10  0.0  0.0  12126  3504 ?        R+   21:32   0:00 ps aux

It is thereby clear, that pid namespace remains separate. A ls will display:

root@container:/# ls
bin  boot  cdrom  dev  etc  lib  lib32  lib64  libx32  lost+found  media  mnt  opt  proc  root  run  sbin  snap  srv  swapfile  sys  tmp  ubuntu-fs.tar  usr  var

The file system is also separate and you can even locate ubuntu-fs.tar within your /.

Show proc pseudo-filesystem mounts in host to establish that container mount points are not visible outside the container:

host@linux:~/tiny-docker$ cat /proc/mounts | grep ^proc
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0

tiny-docker's People

Contributors

wacry 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.