I have image from dockerfile, which setup container, but I need to create and start containers with docker REST API. Problem is that I have issue with exposing ssh port. I have removed EXPOSE from dockerfile, and build image.
After that I made POST request on /containers/create with this json:
{"Image":"frantiseks/apac","ExposedPorts":{"22/tcp":{}},"Memory":600000,"CpuShares":50}
Container was successfully created so as next step I started it with this POST
request /containers/$id/start
with JSON:
{"PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }}
But after inspect container I do not see mapped ports, so container does not exposed 22 to host 11022 port. I am using version 0.7.1.
Could someone tell me what I am doing wrong? Thanks
PS: Inspected container: http://jsonblob.com/52b01e45e4b0439bc58ec8d4
(Apologies for the late answer, "community" decided to bump your question)
With the current 1.24 api, this is all done in the container create. You need to include the following there:
"HostConfig": {
"PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With