import ( "github.com/fsouza/go-dockerclient" "fmt" ) func main() { dockerClient, _ := docker.NewClientFromEnv() containers, _ := dockerClient.ListContainers(docker.ListContainersOptions{}) for _, container := range containers { fmt.Println(container.ID) } }
import ( "github.com/fsouza/go-dockerclient" ) func main() { dockerClient, _ := docker.NewClientFromEnv() dockerClient.PullImage(docker.PullImageOptions{ Repository: "library/alpine", Tag: "latest", }, docker.AuthConfiguration{}) dockerClient.CreateContainer(docker.CreateContainerOptions{ Name: "alpine-container", Config: &docker.Config{ Image: "alpine:latest", Cmd: []string{"echo", "Hello, world!"}, }, }) }In summary, the github.com.fsouza.go-dockerclient Client package provides easy-to-use functions for interacting with the Docker API in Go, such as querying containers and spinning up new containers from images.