Basically i need to something like this
docker run -p something:something --name xxxx imagename
in golang sdk (this one https://docs.docker.com/engine/api/sdks/) for docker api, my current code looks like this
exposedPorts, portBindings, _ := nat.ParsePortSpecs([]string{
"127.0.0.1:8080:2368",
})
// Running the ghost container
createdBody, err := dockerClient.ContainerCreate(context.Background(),
&container.Config{
Image: "ghost:latest",
ExposedPorts: exposedPorts,// it supposed to be nat.PortSet
},
&container.HostConfig{
PortBindings: portBindings,// it supposed to be nat.PortMap
},
&network.NetworkingConfig{},
containerName)
I'm using this https://github.com/docker/go-connections/blob/master/nat/nat.go#L126 ParsePortSpecs function which return (map[Port]struct{}, map[Port][]PortBinding, error) but fail since the container.Config.ExposedPorts is nat.PortSet (it's actually map[Port]struct{} tho) and containter.HostConfig.PortBindins is nat.PortMap
I'm not sure if i want to use this client https://github.com/fsouza/go-dockerclient since my current version of docker API is 1.25 and it doesn't support API version above 1.23