Skip to content

Instantly share code, notes, and snippets.

@mrunalp
Last active August 29, 2015 14:14
Show Gist options
  • Save mrunalp/53d128f4654971033f11 to your computer and use it in GitHub Desktop.
Save mrunalp/53d128f4654971033f11 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
docker "github.com/fsouza/go-dockerclient"
)
func main() {
endpoint := "unix:///var/run/docker.sock"
client, _ := docker.NewClient(endpoint)
opts := docker.CreateContainerOptions{
Name: "ipctest",
Config: &docker.Config{
Image: "kubernetes/pause",
},
}
container, err := client.CreateContainer(opts)
if err != nil {
log.Fatalf("Failed to create container", err)
}
hc := &docker.HostConfig{
Privileged: true,
IpcMode: "container:a85c1b84f30aa99223",
NetworkMode: "container:a85c1b84f30aa99223",
}
err = client.StartContainer(container.ID, hc)
if err != nil {
log.Fatalf("Failed to start container", err)
}
fmt.Println("Container started successfully")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment