Files
moby/client
Sebastiaan van Stijn 83477ce8d0 client: remove custom "headers" type, and use "http.Header" instead
Use http.Header, which is more descriptive on intent, and we're already
importing the package in the client. Removing the "header" type also fixes
various locations where the type was shadowed by local variables named
"headers".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-11 13:14:28 +02:00
..
2016-09-07 11:05:58 -07:00
2023-05-19 20:38:51 +02:00
2023-06-09 09:59:29 +02:00
2023-07-05 23:44:17 +00:00
2022-09-28 01:58:52 +02:00
2022-11-30 17:08:00 +01:00
2022-07-29 23:05:15 +02:00
2023-06-29 00:25:21 +02:00
2023-06-09 09:59:29 +02:00
2022-12-21 11:09:01 +01:00
2018-05-20 13:07:17 +02:00
2018-02-05 16:51:57 -05:00
2018-02-05 16:51:57 -05:00

Go client for the Docker Engine API

The docker command uses this package to communicate with the daemon. It can also be used by your own Go applications to do anything the command-line interface does  running containers, pulling images, managing swarms, etc.

For example, to list running containers (the equivalent of docker ps):

package main

import (
	"context"
	"fmt"

	"github.com/docker/docker/api/types"
	"github.com/docker/docker/client"
)

func main() {
	cli, err := client.NewClientWithOpts(client.FromEnv)
	if err != nil {
		panic(err)
	}

	containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
	if err != nil {
		panic(err)
	}

	for _, container := range containers {
		fmt.Printf("%s %s\n", container.ID[:10], container.Image)
	}
}

Full documentation is available on GoDoc.