I have been playing around with Docker lately in my home lab and have primarily been using the Docker CLI. While going through the documentation, I found that Docker also provides a nice remote REST API which by default, seems to be disabled. I was searching online but could not find any tutorials that provides clear instructions on how to enable the remote API for an Ubuntu Virtual Machine that I recently built to run Docker.

With some trial and error, I was able to finally figure out what was needed and figure I would document this for myself and for anyone else who maybe interested.

If you have Docker running on an Ubuntu (14.04 is what I'm using), you will need to edit /etc/init/docker.conf and update the DOCKER_OPTS variable to the following:

This will have Docker bind to port 4243 which will be used by the Docker Remote API. One you have saved your changes, you will need to restart the Docker process by running the following command:

service docker restart

To test that the Docker Remote API has been properly enabled, we will list the Images currently in Docker (this assumes you have at least pulled down one image from the Docker Hub Registry).

In my environment, I have the following Docker Images:

enable-docker-remote-api-1
Using my Firefox browser and the RESTClient plugin, I can perform a GET operation on the following URL: http://172.30.0.199:4243/images/json as described in the Docker Remote API.

enable-docker-remote-api-2
As we can see from the screenshot above, we see the same Images displayed from the remote API. You can also easily test this by using cURL on the command-line by running the following command:

curl -X GET http://172.30.0.199:4243/images/json

If you are running CoreOS (which I also have running in my vSphere environment), you can enable the Docker remote API by following the documentation here. Hopefully this will be helpful for anyone looking to enable the Remote API but not able to find the exact steps.

14 thoughts on “Quick Tip - How to enable Docker Remote API?

  1. Was wondering how to do this; especially the -H 0.0.0.0:55555 for exposing the docker remote api unsecured, without the fancy authentication stuff, thanks!

  2. Thanks ,that put me in the right direction. However since Ubuntu 16.04 with its systemd docker daemon the /etc/default/docker is no longer effective. Instead you need to create a systemd dropin file.

    I placed such a file under: /etc/systemd/system/docker.service.d/remote-api.conf

    With the contents:

    [Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd -H tcp://127.0.0.1:2376 -H unix:///var/run/docker.sock

    (Yes, the double ExecStart is necessary)

    After that run:
    sudo systemctl daemon-reload // reloading daemon definitions
    sudo systemctl restart docker

Thanks for the comment!