I have a data-container that has persistent data within a volume (say /var/data). That container holds the persistent data for another container with the software.
For a new version of the software, the persistent data needs to be upgraded (structure or layout changed etc). As a result, I want to have another data container with the upgraded data at the same location (/var/data) and still keep the old data-container with its data unchanged.
This way, I can use the old data-container with the old version of the software, in case something goes wrong.
But how can I do that? The steps required to achieve the desired result are not obvious to me.
I can run an upgrade container like
docker run -i -t --name temp --volumes-from data -v /upgraded image /upgrade_script.sh but then, how do I move the upgraded data back to the original position without overwriting the old data? If I do
docker run -i -t --volumes-from temp image cp /upgraded /var/data it will overwrite my old data. Do I have to use a host-mounted volume for the upgraded data, or is there some more elegant solution?