sábado, 26 de março de 2016

Docker - How to enable the Remote API ?

Docker Remote API


Recently, I have been playing around with Docker through the CLI command over the Ubuntu (14.04), and I started getting frustrated with managing some containers by a shell script. Depending on your case or for the initial understanding, run the commands through the CLI is completely enough, but why not move on to the next level ? The Docker has a remote API that can be invoked by Rest service.

So, to start, let's stop the Docker service.
  • service docker stop

To enable the service, just edit the /etc/default/docker and update the DOCKER_OPTS variable to the following: -H tcp://0.0.0.0:2376 -H unix://var/run/docker.sock.


Then, start the Docker service.
  • service docker start

BOOM. Now you can see a JSON through http://localhost:2376/info, with some details about the Docker's state, how many containers are running/paused/stopped and so on.

This link docker_remote_api shows how you can play with the rest service.