How to run Docker commands during Dockerfile build

Hi, I want to run docker commands inside Dockerfile to build image. My project uses docker on build jar phase.
My problem is that I fail to run docker build . on folowing Dockerfile:

FROM docker
RUN docker ps

I receive following error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I know that docker build has many limitations, but I want to bypass it somehow…

Thanks a lot!

what is the use-case?