An easy way to achieve this goal is to execute one or more docker commands in the host to get the necessary information in a loop and save it in a known place (for example, in bash)
while true; do echo `docker ps --format {{.ID}}` > /SOME/KNOWN/FILE; sleep 5; done
and then allow the containers to access this file using volumes.
This is much safer than giving access to the docker socket, and you can improve it to provide all the information you need (ex json with name, ip, uptime, etc.).
Salem source
share