Is it possible to be able to write files in my volume, only if they have not already exited and to never delete my previous files ?
I have a Dockerfile which creates an image called bot. In the image, I have a folder /models which can be empty.
After the image is built, it is pushed to a Nexus/Dockerhub repository.
To build my application on my VM, I have a docker-compose.yml which ,among other things, called the bot image by also specify that the folder /models should be in a volume.
My issue is that, I already have files (file_1, file_2, ...) on my VM in /models, if I do docker-compose down and then docker-compose up -d I keep these files because of my volume. But if I have a new version of my image bot, when I do docker-compose up -d I will call the new version of my image (which is almost what I want) but I will erase the folder /models in my volume with the new /models folder from my image.
Thus, I would want to find a way to write file in my volume, only if they have not already exited and to never delete my previous files.
version: "3.2"
services:
bot:
restart: always
tty: true
volumes:
- type: volume
source: ModelsVolume
target: /models
volume:
nocopy: true
volumes:
ModelsVolume: