Docker in Golang

D31032787209497dd65e151f6e2c6927?s=47 jsa :~
April 16, 2014

Docker in Golang

The most popular / important Go project and how you can do the same.

D31032787209497dd65e151f6e2c6927?s=128

jsa :~

April 16, 2014
Tweet

Transcript

  1. Go Docker The most popular Go project and how can

    you do the same. jamie sa  jamie@spe3d.co Product Manager Speed 3D Inc.
  2. Docker is

  3. A project started by Solomon Hykes http://www.forbes.com/sites/ benkepes/2013/10/29/docker- and-the-timely-pivot/ Almost

    got sold that time.
  4. an open source project to pack, ship and run any

    application as a lightweight container
  5. Open Source Highly active since very begining https://github.com/trending?l=go&since=monthly

  6. Lightweight Container Linux Containers LXC » Kernel namespaces (ipc, uts,

    mount, pid, network and user) » Chroots (using pivot_root) » Kernel capabilities » Control groups (cgroups)
  7. PID namespaces in the 2.6.24 kernel struct upid { int

    nr; /* moved from struct pid */ struct pid_namespace *ns; /* the namespace this value is visible in */ struct hlist_node pid_chain; /* moved from struct pid */ }; struct pid { atomic_t count; struct hlist_head tasks[PIDTYPE_MAX]; struct rcu_head rcu; int level; /* the number of upids */ struct upid numbers[0]; }; November 19, 2007
  8. Go-LXC Go Bindings for LXC in lxc.c pid_t go_lxc_init_pid(struct lxc_container

    *c) { return c->init_pid(c); } ...
  9. Creating an lxc container in Go func main() { c,

    err := lxc.NewContainer(name, lxcpath) if err != nil { log.Fatalf("ERROR: %s\n", err.Error()) } defer lxc.PutContainer(c) log.Printf("Creating container...\n") c.SetVerbosity(lxc.Verbose) if os.Geteuid() != 0 { if err := c.CreateAsUser(distro, release, arch); err != nil { log.Printf("ERROR: %s\n", err.Error()) } } else { if err := c.Create(template, "-a", arch, "-r", release); err != nil { log.Printf("ERROR: %s\n", err.Error()) } } }
  10. Before I try

  11. Most of the appeal for me is not the features

    that Go has, but rather the features that have been intentionally left out.
  12. After that certain date.

  13. Why Go? 1.Static compilation 2.Netural 3.It has what we need

    4.Full development environment 5.Multi-arch build Jérôme Petazzoni, Docker and Go: why did we decide to write Docker in Go?
  14. Jan 19, 2013, Initial commit func (docker *Docker) Create(name string,

    command string, args []string, layers []string, config *Config) (*Container, error) { if docker.Exists(name) { return nil, fmt.Errorf("Container %v already exists", name) } root := path.Join(docker.repository, name) container, err := createContainer(name, root, command, args, layers, config) if err != nil { return nil, err } docker.containers.PushBack(container) return container, nil } by Andrea Luzzardi
  15. Demo

  16. What kind of web serivce do you use? » AWS

    » [.*]Azure » Linode
  17. One More thing

  18. Critical Mass April 19, 2014, Saturday 4PM