Creating custom docker image from existing container


We have successfully initiated ERPNext using an image from Docker Hub. Since we have our own customized apps we would like to create our own custom Docker image.
After installing apps in existing container we created custom Docker image from it. Upon creating a custom Docker image and creating a container using the image, the system throws 500 internal server error. In the error logs we have found that frappe bench starts the worker and the worker exits immediately creating an infinite loop. In the worker logs there is no additional information on what happens.

Please find the relevant details of our server environment below:
Server OS: Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-75-generic x86_64)
Bench version: 5.16.2
ERPNext: v14.18.3 (version-14)
Frappe Framework: v14.28.2 (version-14)

Go thorough this