To understand how a docker image was built, use the command:
$ docker history --no-trunc <IMAGE_ID>
You can build a docker file from an image, but it will not contain everything you would want to fully understand how the image was generated. Reasonably what you can extract is the:
MAINTAINER,ENV,EXPOSE,VOLUME,WORKDIR,ENTRYPOINT,CMD,ONBUILD
parts of the dockerfile.