New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port mapping with Docker remote api #2785
Comments
if i understand you correctly for background mode you don't need to do anything , by default remote API run container in detached mode. for running container you have to create container then start it. eg: for creating container: { and for starting container: { refer doc |
Thank you so much for the reply. I will try it, very useful info. However, I would like to ask the following questions form the last 2 days
More questions later.... Again, thanks. Docker is an exciting and wonderful piece of software, we are very HC From: Pradeep notifications@github.com if i understand you correctly for background mode you don't need to do anything , by default remote API for running container you have to create container then start it. eg: for creating container: { and for starting container: { refer doc — |
@hychan Could you post on the docker-user Google group about this, please? It's the right place to get help from other Docker users and discuss about this. What you're describing isn't a problem with Docker itself. I'll close this issue now. Please feel free to comment. |
Thanks for you reply. I searched the Docker document base both on Docker.io url and google. I was unable to find the docmentation listing all the options as you described. Could you please point me to the document sources for using the various options ? for creating container: { and for starting container: { |
start_container status: 400 |
@gezhiwei8899 those options should be set on container create not container start. An easy way to know what requests should be made, is to put the daemon in debug mode; doing so will output the requests that are made by the docker cli in the logs. For example (starting the daemon manually here, just to show); $ dockerd --debug
...
...
DEBU[2018-03-16T13:16:07.815388475Z] Registering POST, /networks/{id:.*}/disconnect
DEBU[2018-03-16T13:16:07.815497235Z] Registering POST, /networks/prune
DEBU[2018-03-16T13:16:07.815637748Z] Registering DELETE, /networks/{id:.*}
INFO[2018-03-16T13:16:07.816020034Z] API listen on /var/run/docker.sock In another shell, run a container; docker run -d --name mycontainer -p8080:80 nginx:alpine And in the daemon logs, you'll see the requests that were made (
Note that for backward compatibility, it's still possible to set these options on container start, but only if you use the old API version (so use You can find the full API documentation (per version) here: https://docs.docker.com/develop/sdk/#api-version-matrix For example, the API version matching Docker 17.12; https://docs.docker.com/engine/api/v1.35/ |
After 1 hour!!!! the parameter HostIp is required! You can't leave it blank! |
@anselmobattisti do you have more details? Trying API calls without Create a curl -v \
--unix-socket /var/run/docker.sock \
"http://localhost/v1.40/containers/create?name=foobar" \
-H "Content-Type: application/json" \
-d '{"Image":"nginx:alpine", "HostConfig":{"PortBindings":{"80/tcp":[{"HostPort":"8080"}]}}}' Start the container: curl -v \
--unix-socket /var/run/docker.sock \
-X POST \
"http://localhost/v1.40/containers/foobar/start" connect to the container and verify that we get the "Welcome to nginx" page curl -s localhost:8080 | grep Welcome
<title>Welcome to nginx!</title>
<h1>Welcome to nginx!</h1> |
What is the value of HostIp? |
@FrankFang depends what you want it to be published on, but see my example above; if you want the equivalent of the |
I looked at the inputs for creating a container, there is no parameters that allow me to represent this docker CLI command:
docker run -d -p 90:80 myConainer/apache2 /usr/sbin/apache2 cntl -D FOREGROUND
How do I use the remote API to generate a command as above ?
Thanks.
The text was updated successfully, but these errors were encountered: