Last active
August 29, 2015 14:14
-
-
Save mrunalp/53d128f4654971033f11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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