Yes it bad practice to mount the socket directly into the container, I wrote a example within our docker compose repo
So you un-comment the socket proxy container and the ## DOCKER_HOST: tcp://socket-proxy:2375
This example is for a root docker installation, if your using rootless docker then the path if different.