Thats actually a bad idea, you can search the forum for admins who did this and had some bad experiences due to dependencies on database versions.
I think they even lost the whole database.
The whole idea behind a docker compose stack is that you are not depending on other servers versions.