github.com/yourbase/narwhal

Make managing Docker a little more friendly!


Keywords
docker, golang
License
Apache-2.0
Install
go get github.com/yourbase/narwhal

Documentation

Narwhal!

Go Reference

Narwhal is a simplistic wrapper around the Docker Go API.

Examples

For full examples and usage see pkg.go.dev.

// Create a client
client := narwhal.DockerClient()

// Create a container
containerID, err := narwhal.CreateContainer(ctx, client, os.Stdout, narwhal.ContainerDefinition{
  Image: "ubuntu:latest",
})

// Start a container
err := narwhal.StartContainer(ctx, client, containerID)

// Copy a file into a container
f, err := ioutil.TempFile("./", "tmpfile")
err = narwhal.UploadFile(ctx, client, containerID, "/tmp/tmpfile", f.Name())

// Execute a command in a container
err := narwhal.ExecShell(ctx, client, containerID, "echo 'Hello world!'", &narwhal.ExecShellOptions{})