How to test dockerized flask app using Pytest?

I’ve built the flask app that designed to run inside docker container. It will
accept POST HTTP Methods and return appropriate JSON response if the header key matched with the key that I put inside docker-compose environment.

...
    environment:
      - SECRET_KEY=fakekey123
...

The problem is: when it comes to testing. The app or the client fixture of
flask (pytest) of course can’t find the docker-compose environment. Cause the app didn’t start from docker-compose but from pytest.

secret_key = os.environ.get("SECRET_KEY") 
# ^^ the key loaded to OS env by docker-compose
post_key = headers.get("X-Secret-Key")
...

if post_key == secret_key:
    RETURN APPROPRIATE RESPONSE
       .....

What is the (best/recommended) approach to this problem?

I find some plugins
one,
two,
three to do this. But I asked here if there is any more “simple”/”common” approach. Cause I also want to automate this test using CI/CD tools.

Source: StackOverflow