Skip to content

Writing a container in a few lines of Go code, as seen at DockerCon 2017 and on O'Reilly Safari

License

Notifications You must be signed in to change notification settings

dacarey/containers-from-scratch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Containers from Scratch

Writing a container in a few lines of Go code, as demonstrated by Liz Rice at DockerCon 2016 and on O'Reilly Safari

This is forked from Liz Rice's original repository, purely to allow me to add some extra setup notes for a local demonstration to developers at the company i work at.

Massive kudos to Liz for this. It really showcases how the underlying concepts of cgroups, namespaces, chrooted file systems ( a.k.a images) can be put together to form the bigger concept of a 'container'. They say 'a picture is worth a thousand words', well there is a similar analogy with this demo!

How I run this on Linux

sudo env "PATH=$PATH" go run main.go run /bin/bash

This is to avoid a common error fork/exec /proc/self/exe: operation not permitted

How I build the container Filesystem

rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/home/*","/opt/*","/snap/*","/usr/local/*","/usr/src/*","/var/*","/vagrant/*"} /vagrant/rootfs

Kudos to this StackExchange thread and answere

Remember to then also create the mytemp directory. It is helpful to create a directory CONTAINER_FILESYSTEM ( yes in uppercase) so it is obvious that you are in that directory when you start the container.

About

Writing a container in a few lines of Go code, as seen at DockerCon 2017 and on O'Reilly Safari

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%