Reputation: 46
I have deployed an application using docker and docker-compose but now as I want to add some new code in my application, what do I need to do in order to get those changes without restarting my container?
Upvotes: 2
Views: 3379
Reputation: 42501
This really depends on how your application is built in general.
For example if you have a java process that uses compiled code, then by default you'll have to re-build the docker image (run docker build
or use docker-compose syntax that builds the image, it will do the same under the hood) and restart the container.
In the same java universe, if you have, say Tomcat as a server that hosts some WAR file, then you can only reload the WAR file itself, and you won't need to restart the process of tomcat (the docker process).
If your application is a bunch of java script files, served by node server, then you have options.
For all types of applications: If you don't want to rebuild image every time - you can create a volume and place the application code artifact into the volume. The process will "assume" that the volume is mounted (it will see it just as a folder in its filesystem) and will run it. So instead of re-building the image you'll place the artifact into the volume which can be also exposed as a folder on a host machine. For production this is not recommended, but you can use it for development (although you should have a reason to use docker for development, why not running the process directly).
For applications that can be reloaded by placing the Java Script file(s) - you won't have to reload the process with the method that I've described above.
Upvotes: 3