I have create the custom docker image. Now whenever I make the change in code, I have to again build the custom image.
Please share your thoughts if anyone knows how to run the docker in development mode so that I can get the changes without building the docker image again.
Thanks & Regards,
I am not exactly sure what “docker in development mode” is supposed to be, but I guess you are looking for using a volume-bind to mount a host folder into a container folder for hot code deployment.
Note: if you bind a host folder into a container folder, the content of the host folder will eclipse the original content of the container folder. You will need to make sure that the host folder has all the required files in it, because otherwise your container might fail to start.
Note: due to a lack of provided information, I can not tell you which host folder to map into which container folder. This highly depends on the programming language used, the image design and wether your language/runtime even supports hot code deployment. If it doesn’t support hot code deployment you will still need to restart the container.
I am using python as a programming language. Development mode means every time we made the change in the code we suppose not to run “docker-compose up --build” docker command. It should take that changes. If we run the “docker-compose up --build” command again it will take some time to build the containers/Image.
I have already doing volume binding, still I need to run the build command every time.
I tried with “docker-compose up” command as well but changes are not getting reflecting without running build command.
Please suggest any inputs on this.
Thanks & Regards,
You need to wait till someone comes around who actually writes code in python. I can’t tell you if python does hot code replacement/deployment when the application is still running.
Abhilash, this should be possible when your Python code is mounted as a volume, and not packaged into the container image during build. As Metin said above, in this way the changes you make are reflected immediately in the container.
I’m not an expert in Python, but here’s one post I found doing this: How to Develop Your Python Docker Applications Faster - DZone Microservices
Also when using docker-compose you shouldn’t need to rebuild all of the containers. Just the one with the relevant Python code that has changed. Try “docker-compose build --no-cache pythonApp” for something like that.