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:

    sudo vi /lib/systemd/system/docker.service
  • Modify the line that starts with ExecStart to look like this:
    ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://

    Where my addition is the “-H tcp://” part.

  • Save the modified file.
  • Make sure the Docker service notices the modified configuration:
    systemctl daemon-reload
  • Restart the Docker service:
    sudo service docker restart
  • Test that the Docker API is indeed accessible:
    curl http://localhost:4243/version

    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

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!

20 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:// -H unix:///var/run/docker.sock


  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:// -H unix:///var/run/docker.sock’

    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:// -H unix:///var/run/docker.sock

      1. Bibekananda Mantry

        Yes it worked , “/usr/bin/dockerd” not “/usr/bin/docker daemon ” in case of ubuntu 16.04

  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.

    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!

  4. Raitis

    Man… there are a few articles online on how to enable remote docker access. I always need to find this particular one, cause none of the other ones work. 😀

  5. Lucas Jellema

    After trying out many other articles and suggestions, I finally arrived at your article and that did the trick for me on Ubuntu Xenial and Docker 17.06. Thanks very much for sharing!

    kind regards

  6. Pingback: 通过暴露的docker.sock文件接管容器 – NEWS.ALL

  7. Pingback: pycharm can’t complete remote interpreter setup for Docker – Config9.com

Leave a Reply

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