Okta authentication with Flask-OIDC on Docker not working

I am using Flask-OIDC to integrate Okta authentication with my Flask application. I provided client secrets and redirect URIs for Flask-OIDC setup: 'http://localhost:5000/oidc/callback'. When I run this Flask application on my local using wsgi, the login flow works fine. It redirects me to Okta and upon entering credentials, it redirects me back to my logged in app.

But when I run the exact same application using uwsgi in a docker container, it fails. The error message I get is dev-xxxx.okta.com redirected you too many times. I tried debugging by printing all the intermediate values between local and docker webapps, but both seem to be following the exact same flow! After looking at https://devforum.okta.com/t/infinite-loop-in-the-sign-in-page/1207/4 , I added another uri to my OKTA_REDIRECT_URIS: 'http://<docker-ip-address>:5000/oidc/callback'. But to no avail. I still get infinite redirection. Can somebody please help me with this? Thanks in advance!

Source: StackOverflow