I am trying to run a Docker container using Go SDK. From the terminal, I can run the following command with no issues :
docker run -d --memory 1024M --name "cdb1" -p 2001-2006:8091-8096 -p 11210-11211:11210-11211 couchbase
I want to achieve the same thing using the Docker SDK for Go but cannot find how to reproduce the -p 2001-2006:8091-8096
part. Here is my ContainerCreate call :
cont, err := cli.ContainerCreate(
context.Background(),
&container.Config{
Image: "couchbase",
ExposedPorts: nat.PortSet{
"2001-2006": struct{}{},
"11210-11211": struct{}{},
},
},
&container.HostConfig{
PortBindings: nat.PortMap{
"8091-8096": []nat.PortBinding{
{
HostIP: "0.0.0.0",
HostPort: "2001-2006",
},
},
"11210-11211": []nat.PortBinding{
{
HostIP: "0.0.0.0",
HostPort: "11210-11211",
},
},
},
Resources: container.Resources{
Memory: 1024 * 1000000,
},
},
nil,
"cdb1",
)
But running this always throw the same error :
Error response from daemon: invalid port specification: "8091-8096"
Doing some more testing, the error seems to come specifically from the PortBindings
part (if I remove this one and leave the exposed ports, it works fine).
I couldn't find anything about this on Docker documentation.