Table of Contents
Enable Docker Remote REST API on Docker Host in Ubuntu
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
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
123ExecStart=/usr/bin/docker daemon -H=fd:// -H=tcp://0.0.0.0:2375
- Save the Modified File
- Reload the docker daemon
- Restart the container
123sudo service docker restart
- 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