How to Enable Docker Remote REST API on Docker Host - Little Big Extra Skip to main content

How to Enable Docker Remote REST API on Docker Host

Enable Docker Remote REST API on Docker Host in Ubuntu

 

Introduction

Docker provides remote REST API which is beneficial if you want to connect to a remote docker host. Few of the functions which you can achieve using Docker REST API over a simple browser are

  • Create and Manage Containers
  • Get low-level information about a container
  • Get Container Logs
  • Start/Stop container
  • Kill a container
My remote docker host was an Ubuntu Virtual Image on Microsoft Azure.

In this tutorial, I will show you

  • What didn’t worked?
  • What really worked.

Things that didn’t worked

Over the internet, most of the people have suggested editing DOCKER_OPTS variable.

  • I changed DOCKER_OPTS in the /etc/default/docker file but it didn’t have any effect
  • Then I tried changing DOCKER_OPTS in the file /etc/init/docker.conf but again no success.

What really worked for me to enable docker remote API on docker host

  • Navigate to /lib/system/system in your terminal and open docker.service file
  • Find the line which starts with ExecStart and adds  -H=tcp://0.0.0.0:2375 to make it look like
  • Save the Modified File
  • Reload the docker daemon
  • Restart the container
  • Test if it is working by using this command, if everything is fine below command should return  a JSON
  • To test remotely, use the PC name or IP address of Docker Host
Please note that docker standard TLS port is 2376 and 2375 are the standard unencrypted port. As we have defined 0.0.0.0, which defines an open interface for everyone. Anyone with network access to this port will have full root access on the host. I have restricted the access by creating an access-controlled list in Azure so please follow some similar mechanism to restrict access

Related Posts

2 thoughts to “How to Enable Docker Remote REST API on Docker Host”

  1. Or use docker.

    docker run -d \
    –name sherpa \
    -v /var/run/docker.sock:/tmp/docker.sock \
    -p 2375:4550 \
    djenriquez/sherpa –allow

  2. This works for packages installed via apt, but the config files are different with snap. Where can the -H be set when docker is installed via snap?

Leave a Reply

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

Bitnami