I had the same error.
In my case the reason was that in my script when i started a session
from sqlalchemy import create_engine
engine= create_engine(DATA_BASE_URL, connect_args={"check_same_thread": False})
I used as DATA_BASE_URL a mounted directory outside my container
And when i changed it to the directory inside the container the issue was resolved
So make sure that you pass database url that strats with "/app/{your database location inside the container}"