I have a container ==> FROM node:5
Node should restart after each change in the code.
But there is no way for me restart the Node server without restarting the whole docker container.
I have many npm install
on dockerfile that runs each time I restart the container, and it's annoying to wait for all of them after each change in the code.
I'm already using shared folder to have the latest code in my container.
For a major version upgrade, one has to tear down all running containers. With a restart policy of always , however, the containers will be restarted after the docker daemon is restarted after the upgrade.
On Linux, you can avoid a restart (and avoid any downtime for your containers) by reloading the Docker daemon. If you use systemd , then use the command systemctl reload docker . Otherwise, send a SIGHUP signal to the dockerd process.
A reload will not impact your containers, unlike a full daemon restart. Live restore should now be activated. You can test it out by stopping the Docker daemon.
If you just need the Node.js server to restart after changes, instead of starting the server with the node
command you can use a tool like node-dev or nodemon. To leverage these, you'd need to update the command in your Dockerfile, e.g. CMD [ "node-dev", "server.js" ]
.
Since you already have your local files as a volume in the Docker container, any change to those files will restart the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With