How can i run docker command inside a docker container?

I was looking for container IP with docker inspect command,
I am running containers with docker-compose. I had mounted the /var/run/docker.sock in docker-compose’s volumes section, after I was able run docker command with python scripts.