5

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

2
  • No I did not, I found workaround to use only docker internal LAN, and not to exposed any ports. Commented Feb 13, 2014 at 6:45
  • Can you please upgrade to latest version and see if problem resolves? Commented Mar 14, 2014 at 17:55

2 Answers 2

2

(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" }] }, } 
Sign up to request clarification or add additional context in comments.

Comments

0

Did you try: {HostIp:"", HostPort:"11022"} ?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.