reading the doc from docker remote api I get issue when start my container using the API https://docs.docker.com/engine/api/v1.41/#operation/ContainerCreate
The doc at the "Publish or expose port (-p, --expose)" section talks about use the -p to bind a port to application. Using the docker remote api I create the container using this payload
POST http://[...]/containers/create
{
"Image": "correiosimg",
"ExposedPorts":{
"0.0.0.0:80:8089/tcp":{}
}
}
but when I call the endpoint to start the container, It takes the port "0/tcp" on docker console.. the service starts, but inacessible
my docker ps console: https://i.stack.imgur.com/V53Mc.png docker compose file: https://i.stack.imgur.com/ueC2f.png
tkss!
The setting you show is for the essentially meaningless "expose" option. You need to "publish" ports instead. That operation is in
"HostConfig"
"PortBindings"
; it is an object with the container ports as keys and a small object with values.So the API request body you need might look a little more like