The official Microsoft documentation recommends to use bind mount in order to run docker inside the agent. Considering security implications of mounting Docker socket, I have installed a complete Docker inside the agent image itself.
docker run -e AZP_URL=<Azure DevOps instance> -e AZP_TOKEN=<PAT token> -e AZP_AGENT_NAME=<agnet name> -e AZP_POOL=<pool name> parsa2820/azure-agent-dind:latest
docker build .