WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Quick Tip - How to enable Docker Remote API?

Quick Tip - How to enable Docker Remote API?

07.27.2014 by William Lam // 18 Comments

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:

DOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'

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.

More from my site

  • Configuring Github Actions self-hosted runners on PhotonOS 
  • Project USB to SDDC - Part 3
  • Quick Tip - Creating a multiline Dockerfile using heredoc w/variable substitution
  • Easily try out vSAN 6.6 Encryption feature using KMIP Docker Container
  • Project USB to SDDC - Part 2

Categories // Automation, Docker Tags // Docker, docker.conf, remote api

Comments

  1. *protectedJay says

    09/13/2014 at 5:46 pm

    Very helpful! Thank you!

    Reply
  2. *protectedm says

    12/17/2014 at 8:57 pm

    The service command does not exist on my docker installation?

    Reply
    • *protectedArtworkAD (@artwork_ad) says

      01/06/2015 at 4:34 pm

      You have to put it in /etc/default/docker

      Reply
  3. *protectedSigmund Lundgren (@sigmundl) says

    02/24/2015 at 3:16 pm

    Why don't you use the default 2375 port?

    Reply
  4. *protectedVishal Biyani (@vishal_biyani) says

    06/30/2015 at 12:31 am

    Thank you! This helped immensely!

    Reply
  5. *protectedmatheeeny says

    07/15/2015 at 2:52 pm

    Why not put this in /etc/defaults/docker?

    Reply
    • *protectedstampycode says

      02/12/2016 at 3:29 am

      because the config file is at `/etc/default/docker` (not "defaults") 😀

      Reply
  6. *protectedANVIKA says

    05/28/2016 at 9:24 am

    Please describe the same for windows !! I really need it 🙂 thanks in advance.

    Reply
  7. *protectedRyan Schroeder says

    06/07/2016 at 11:48 am

    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!

    Reply
  8. *protectedOliver Weise says

    08/18/2016 at 6:00 am

    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

    Reply
    • *protectedBryan Robbins says

      11/06/2016 at 4:17 pm

      +1 for this. The same works for any systemd-based system (such as RHEL/CentOS 7).

      Also shown here: recommend binding on 127.0.0.1 instead of 0.0.0.0, unless you have a good reason!

      Cheers.

      Reply
    • *protectedJohn says

      12/05/2016 at 1:53 pm

      +1

      Reply
  9. *protectedJustin Lee says

    08/18/2016 at 8:26 am

    Thank you for this very helpful documentation!

    Reply
  10. *protectedDJ Enriquez (@denriquezjr) says

    10/18/2016 at 11:07 pm

    Instead of changing the Docker daemon configuration and restarting it, you can run Sherpa, a container that opens up a port to the unix socket via reverse-proxy. Check it out: https://hub.docker.com/r/djenriquez/sherpa/

    Reply
  11. *protectedgpk09 says

    12/14/2016 at 4:47 am

    Really this article has helped me, thanks for great share

    Reply
  12. *protectedRaj says

    02/03/2017 at 11:02 am

    Thats an awesome article .. Thank you

    Reply
  13. *protectedPankaj says

    06/12/2017 at 1:22 am

    This doesn't work on 16.04. However, its on similar lines. Please following instructions at https://www.ivankrizsan.se/2016/05/18/enabling-docker-remote-api-on-ubuntu-16-04/ for the same.

    Reply
  14. *protectedNavaneetha Kandethodi says

    12/19/2017 at 7:22 pm

    Now the modification in /etc/defaults/docker does not work. Please refer to following working solution
    http://www.littlebigextra.com/how-to-enable-remote-rest-api-on-docker-host/

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • VMware Flings is now available in Free Downloads of Broadcom Support Portal (BSP) 05/19/2025
  • VMUG Connect 2025 - Minimal VMware Cloud Foundation (VCF) 5.x in a Box  05/15/2025
  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...