How can I use REST API to interact with the Docker engine?
You need to expose the Docker daemon on a port.
You can configure the Docker daemon to listen to multiple sockets at the same time using multiple -H options:
listen using the default Unix socket, and on two specific IP addresses on this host.
$ sudo dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
The Docker client will honor the DOCKER_HOST environment variable to set the -H flag for the client. Use one of the following commands:
https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option
You need to do this by creating a systemd dropin:
mkdir -p /etc/systemd/system/docker.service.d/cat > /etc/systemd/system/docker.service.d/10_docker.conf <<EOF[Service]ExecStart=ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:2376EOF
Then reload and restart Docker:
systemctl daemon-reloadsystemctl restart docker
Note: this way you would be exposing your host and you shouldn't do it this way in production. Please read more about this on the link I shared earlier.