Go Docker Command is a Go library that provides a fluent interface to manage Docker containers, in the manner of the Docker CLI
We use the great fsouza/go-dockerclient to communicate with the Docker engine.
Note: Requires at least go 1.3
Start a nginx container with go-dockercommand
package main
import (
"fmt"
docker "github.com/bywan/go-dockercommand"
)
func main() {
// Create go-dockercommand client
client, err := docker.NewDocker("")
if err != nil {
fmt.Printf("Error creating go-dockercommand client, error is: %v", err)
}
// Create a nginx container
_, err = client.Run(&docker.RunOptions{
Name: "test",
Image: "nginx",
Detach: true,
})
if err != nil {
fmt.Printf("Error Starting Docker Container, error is: %v", err)
}
}