Configure remote access for Docker daemon | Docker Docs
Please note opening TCP to the Docker Engine is a security risk.
Connection to the containers can provide root access. Ensure that necessary firewall restrictions are in place to allow only expected clients. Within a Cloud environment external access is typically blocked by default but access from other machines within the virtual network need to be considered.
Edit the systemctl service override:
sudo systemctl edit docker.service
The Docker instructions specify using 127.0.0.1, which will only bind to the localhost interface. To permit external connections, 0.0.0.0 will listen on all interfaces, you can modify this to a specific interface IP as required.
Add these lines between the top comments:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375
Save the file (CTRL+X) and reload the systemctl configuration.
sudo systemctl daemon-reload
Restart Docker
sudo systemctl restart docker.service
Within AWS the VM Security Group settings must receive a new port rule to allow 2375 from any specific clients that need to connect. Also a port range for the containers is required (if 10 containers may run in parallel, use 5000-5009):
