The best way I found to confirm the actual issue is to go into the container in debug mode(docker run -it --entrypoint sh "image"). You can then check env and confirm the version is the issue. Just update your env to YARN_VERSION=version required and test.
You can modify your dockerfile or image accordingly.