Skip to content

Make managing Docker a little more friendly!

License

Notifications You must be signed in to change notification settings

yourbase/narwhal

Repository files navigation

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{})