Enabling Docker Remote API on Ubuntu 16.04

By | May 18, 2016

I tried to find instructions on how to enable the Docker remote API when running Docker in Ubuntu 16.04, but none of the instructions I came across managed to take me all the way, so here are a few short notes on how I managed to accomplish this:

  • Edit the file /lib/systemd/system/docker.service
    I used the vi editor:
  • Modify the line that starts with ExecStart to look like this:

    Where my addition is the “-H tcp://0.0.0.0:4243” part.
  • Save the modified file.
  • Make sure the Docker service notices the modified configuration:
  • Restart the Docker service:
  • Test that the Docker API is indeed accessible:

    You should see output similar to this as the result:
  • To access the Docker API from another computer, use the IP address of the Ubuntu computer found at either wlan0 or eth0, depending on whether you use wifi or ethernet network connection.
    To learn the IP addresses of the different interfaces, use the ifconfig command in a terminal window. In my case it is 192.168.1.68.

Finally, this screenshot shows how to set up access to the Ubuntu computer’s Docker API from inside IntelliJ IDEA with the Docker plug-in installed. I only modified the API URL and left the path to the certificates folder unchanged.

Setting up access to a remote Docker daemon in IntelliJ IDEA.

Setting up access to a remote Docker daemon in IntelliJ IDEA.

Happy coding!

10 thoughts on “Enabling Docker Remote API on Ubuntu 16.04

  1. Philipp

    Thanks a lot, this helped me out!

    However, on my system (also Ubuntu 16.04) I had to add the following option to be able to execute docker commands from shell:
    -H unix:///var/run/docker.sock

    Thus, my config line in /lib/systemd/system/docker.service reads as follows:
    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock

    Best,
    Philipp

    Reply
  2. stefan

    Hi All,
    Just a quick note you can also edit the DOCKER_OPTs in /etc/init/docker.conf. Simple change the line to look like:
    DOCKER_OPTS=’-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock’
    Thanks
    Stefan

    Reply
    1. Rishi Rakshit

      This file only exist in few of the OS for example it dose not exits on CentOS , so we have add it in
      ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock

      Reply
  3. Scott

    Not sure if this is a change but under “Ubuntu 16.04.1 LTS” (from lsb_release -d) I got a warning when restarting Docker:
    Warning: docker.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
    If I didn’t do this Docker didn’t pick up the change to the docker.service file.

    Reply
    1. Ivan Krizsan Post author

      Hi Scott!
      Yes, you are correct – I have seen this before but it seems I forgot to include that step. Post is now updated!
      Thanks!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *