====== Docker - Networking - Enable Docker Remote API ======
Docker provides a nice remote REST API.
Edit or create a systemd dropin 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:1234 -H unix:///var/run/docker.sock
**NOTE:** The double ExecStart is necessary!
The following can be used instead of the 2nd ExecStart above. **-H fd://** can also be used to refer to systemd's socket activation feature /lib/systemd/system/docker.socket.
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:1234
It is recommended binding on 127.0.0.1 instead of 0.0.0.0, unless you have a good reason!
This will have Docker bind to port 1234 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:
sudo systemctl daemon-reload
sudo systemctl restart docker
Check that the dockerd process listening on port 1234:
sudo ss -tulpn | grep 1234
tcp6 0 0 :::1234 :::* LISTEN 1836/dockerd
To test that the Docker Remote API has been properly enabled, we will list the Images currently in Docker:
sudo docker images
Test by performing a GET operation on the following URL: http://172.30.0.199:1234/images/json as described in the [[https://docs.docker.com/engine/api/|Docker 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:1234/images/json
----
===== References =====
https://docs.docker.com/engine/api/
https://docs.docker.com/engine/security/
http://www.littlebigextra.com/how-to-enable-remote-rest-api-on-docker-host/