I'm trying to run a Python code in a Docker container. I'm using the debug tool with the VScode Python extension. I have a .env file in the same directory as Docker-Compose, but when I run the code in debug mode, the .env file is not read. If I access the container via the command line and run export, the environment variables are in the container. However, the Python code below does not print them: import os from dotenv import load_dotenv if __name__ == "__main__": load_dotenv(dotenv_path="/home/project/app/.env") envVar=os.environ print(envVar) In docker-compose.yml I added the field: env_file: - .env In launch.json I added: "envFile": "${workspaceFolder}/.env", In settings.json I added "python.envFile": "${workspaceFolder}/.env", And now I don't know what to do to get the environment variables read in the python code. Continue reading...