How to Enable Docker Engine RESTful API

Alexander Ibrahim
2 min readJun 21, 2020

Your docker swarm is scaling up, you have cluster/system monitor, you have alerting system, now what? now you need to scale up or down your cluster automatically, so we need access docker daemon remotely. But by default docker automatically enable remote access. So now we try to enable docker remote via RESTful. Let us start.

  1. SSH to your server
  2. edit following file sudo vi /lib/systemd/system/docker.service ,
edit the red line above

3. add following command -H=tcp://0.0.0.0:2375 to the line,

enable access tcp with port 2375

4. save the file,

5. run commandsudo systemctl daemon-reload,

6. run command sudo service docker restart

7. pull some image for the test docker pull alpine:latest,

8. exit the server,

9. if you are using aws, do not forget to setup your aws security group to enable port 2375 ,

10. try curl http://[your ip]:2375/images/json

Now you can control your docker swarm remotely. Let us have some fun.

--

--