How to Enable Docker Engine RESTful API
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.
- SSH to your server
- edit following file
sudo vi /lib/systemd/system/docker.service
,
3. add following command -H=tcp://0.0.0.0:2375
to the line,
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.