How to make changes in container and restart service without loosing changes?



Hello. I have a bunch of microservices deployed in Kubernetes (each pod has only one docker container).
I need to add one file to one container and restart service there, otherwise file will be not visible to that service. If I kill the only running process with that service - whole container will be stopped. After starting container or other manipulations to restart it - all changes become lost, because docker container is always being built from scratch.
So, is there any possibility to apply that changes and restart service? I have no access to Dockerfile or something like this. All deployment is done by automation script which is run playbooks and so on.


You usually don’t want to do what you say: it creates problems if a node crashes (your file won’t be there, etc.).

So you should really think if you really want to do that.

If you do, you should check a way to restart the service without it being killed. Several services allow to receive some signal and re-read configuration files.

If you can’t do that, then I think there is no way. If the process does not support any way to read configuration files without a restart, then you won’t be able to read them without a restart… :-/

If you don’t need to have files created manually, then you can restart the pods and mountain your files his configmap volume. If this an option to you (not clear from your original description), then this would be the best, I think.