jamie sa 撒景賢 jamie@spe3d.co Product Manager Speed 3D Inc.
^ ex founder of Waveface mostly Cocoa in past 3 years
^ anyone heard of it, anyone try in before
http://www.forbes.com/sites/benkepes/2013/10/29/docker-and-the-timely-pivot/
^ First some background. dotCloud is in a very busy space, the PaaS landscape is rapidly converging on a few ecosystems of note. There is Heroku, the
Almost got sold that time.
Highly active since very begining https://github.com/trending?l=go&since=monthly
Linux Containers LXC
^ The goal of LXC is to create an environment as close as possible as a standard Linux installation but without the need for a separate kernel.
```c 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]; }; ```
^ Thinking in chroot or jail
Go Bindings for LXC
in lxc.c
c
pid_t go_lxc_init_pid(struct lxc_container *c) {
return c->init_pid(c);
}
...
—
#Creating an lxc container in Go
```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())
}
} } ```
Before I try
^ read effetive go if you haven’t.
After that certain date.
Jérôme Petazzoni, Docker and Go: why did we decide to write Docker in Go?
^ easy to install, deploy ^ not C++, Python, Ruby, Java ^ asynchronous primitives, ^ doc, get ,fmt, test run ^ _linux, _darwin
```go 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
^ A googler now
Demo
^ The prefix changes from time to time
One More thing
April 19, 2014, Saturday 4PM