import ( "github.com/fsouza/go-dockerclient" ) func main() { endpoint := "tcp://localhost:2375" // Docker daemon endpoint client, _ := docker.NewClient(endpoint) config := &docker.Config{ Image: "nginx:latest", } hostConfig := &docker.HostConfig{ PortBindings: map[docker.Port][]docker.PortBinding{ "80/tcp": {{HostIP: "0.0.0.0", HostPort: "8080"}}, }, } container, _ := client.CreateContainer(docker.CreateContainerOptions{ Config: config, HostConfig: hostConfig, Name: "test", }) }In this example, we create a new Docker container with the image "nginx:latest" and bind container port 80 to host port 8080. The container is named "test". This function returns the created container object on success. Package Library: `github.com/fsouza/go-dockerclient`