Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is equivalent remote api command to 'docker run -d'?

I'm trying to call docker commands via remote api.

Docker remote api does not seem to have 'Detached mode' option. http://docs.docker.io/en/latest/commandline/command/run/

I could use this app in the bash, and I would like to use this via remote api. https://github.com/grigio/docker-stringer

like image 899
user966151 Avatar asked Jul 21 '13 20:07

user966151


People also ask

Does Docker have an API?

Docker provides an API for interacting with the Docker daemon (called the Docker Engine API), as well as SDKs for Go and Python. The SDKs allow you to build and scale Docker apps and solutions quickly and easily. If Go or Python don't work for you, you can use the Docker Engine API directly.

What is the Docker Run command?

The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command. That is, docker run is equivalent to the API /containers/create then /containers/(id)/start .


2 Answers

Indeed, the remote API does not have a 'detach' mode as the 'attach' mode is an extra endpoint.

If you want to run in detach mode with the remote API, simply create and start your container without attaching to it.

If the container still shuts down immediately, use docker logs <container id> to check for errors. The problem might have nothing to do with detach.

like image 144
creack Avatar answered Oct 27 '22 17:10

creack


It's important to understand the "docker run" command encapsulates a series of commands from an API perspective:

  • pull image (if not available locally)
  • create the container
  • attach to the container
  • starts the container

While "docker run -d" is the same thing as above but without the "attach" step.

Therefore, you need to create and then start your container when using the remote API.

If the container still shuts down immediately, use docker logs <container id> to check for errors. The problem might have nothing to do with detach.

like image 26
juliaaano Avatar answered Oct 27 '22 15:10

juliaaano