How to downgrad version of PHP in docker

I want to change the php version in Docker from 7.4.16 to 7.1 but I have not been able to do so yet.
I have already edited Docker file and docker-compos, but unfortunately I could not change the php version.