Skip to content

bfirsh/docker-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker SDK for Go

A Go library for controlling Docker and building apps on top of Docker.

Usage

Import this library, and it will be available as docker:

import "github.com/docker/docker-sdk-go"

Running a container:

client, err := docker.FromEnv()
if err != nil {
    return err
}

container, err := client.Containers.Run(&docker.RunOptions{
    Image: "alpine",
    Cmd: []string{"echo", "hello world"},
})

if err != nil {
    return err
}

out, err := container.Logs(nil)
if err != nil {
    return err
}

fmt.Printf("%s", out)

Running a detached container:

client, err := docker.FromEnv()
if err != nil {
    return err
}

container, err := client.Containers.Run(&docker.RunOptions{
    Image:  "bfirsh/reticulate-splines",
    Detach: true,
})
if err != nil {
    return err
}

out, err := container.Logs(nil)
if err != nil {
    return err
}

fmt.Printf("%s", out)

if err := container.Stop(nil); err != nil {
    return err
}

About

WIP: Prototype of a better Go client for Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published