Someting wrong with bind

I build the container with docker run -d --mount type=bind,source=./app,targert=/app.my code is run with python and all of sub-file is called with subprocess.run
the develop environment is Ubuntu 5.4.0 docker version is 24.0.7 and deploy environment is Deepin.
In most cases, I can replace the file without docker restart. But one day in deploy environment, I replace the files of whole project without docker restart. It work wrong, it output the unexpected results( json with read exsited file,but file it is not existed and output the wrong results) without exception or error( In common, it will throw the exception in python process and write log in local file,but nothing work) and no logs outputed in docker logs untill I restart the whole process of docker. which wrong with it and It is safe to replace the file without docker restart and how to avoid it ?

In general I would not expect Python to restart the app automatically, because a file has changed. I am mostly using NodeJS, and I have to setup a special watch process to handle this.

I’m not sure I understand the description. What is

You mean the Linux Kernel version? Ubuntu has a completeley different versioning strategy.

Also What is a sub-file?

You mean just files in /app and you execute the files using subprocess.run?

If you want “hot reload”, I’m not a python developer so I can’t answer it myself, but I found this:

Docker will not solve it for you.

Search for the PYTHONUNBUFFERED variable either on Google or even here on the forum. My only guess is that you haven’t set that and a simply “print” instruction will not send the output directly to the terminal. The logging module could.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.