error retrieving current directory: getcwd in Docker container

I’m running the ‘php:7.4-fpm’ container to server a laravel application. When I tried to ssh into the container, I got the following error:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

This happened suddenly, I’m working on this project for almost 3 months and had never faced this scenario.
My host machine is a mac, catalina (version 10.15.3)

I can run other commands like php/ php artisan etc but its taking too long to respond and also any command related to directories like getcwd/pwd etc are not working.

Why does this happen?

It works fine after restarting the containers but is there permantent solution?

Source: StackOverflow