Okay so I was on a quest to get my Flask app to print to console from within a docker container, and nothing was working. I tried the sys.file=stderr, the "flush" methods, nothing was working. So I tried to import the "logging" library and I set logging.basicConfig(level=logging.DEBUG). Now I don’t actually know what this does, I just saw it on a Youtube tutorial about how to print to console without the "print()" function. So in one of my application files, I typed a silly message with curse words just to see if it was working, but that was in a previous attempt, BEFORE setting logging.basicConfig(level=logging.DEBUG). I erased that message with the curse words from the file. However, now, AFTER setting logging.basicConfig(level=logging.DEBUG), every time I spin up the Flask app within the Docker container, it prints the obscene message TWICE even though that message is NOT in any of the files! I even erased the files completely and recopied them into the directory, but the message still shows up! I rebuild the Docker image every time I run the app within the container, so I know it’s getting the updated versions of the files… Wat the hell did I do and how do I get the message to go away? It only happens when I run the app inside the Docker container, btw….anyone know what to do??
Source: Docker Questions