import ( "github.com/docker/docker/engine" ) client, _ := engine.NewClient("unix:///var/run/docker.sock") containerConfig := engine.Env{ "Image": "nginx", } hostConfig := engine.Env{ "PortBindings": engine.Env{ "80/tcp": []engine.PortBinding{{ HostIP: "0.0.0.0", HostPort: "80", }}, }, } container, _ := client.CreateContainer(containerConfig, hostConfig, nil)
import ( "github.com/docker/docker/engine" ) client, _ := engine.NewClient("unix:///var/run/docker.sock") containerID := "abc123def456" client.StartContainer(containerID, nil)In this example, we create a new Docker client and use it to start an existing container with the ID `abc123def456`. Overall, the `github.com/docker/docker/engine` package is a useful tool for developers who want to interact with the Docker engine programmatically.