Reputation: 349
I'm looking for some help. If I use docker run
to run a container and I have used -v
to mount to a volume that already has files contained (these files are the files from a previous run of the container but with a config file edited). Will the container I run then use the contents of the files I have overwritten or will it use the files within the container anyways and disregard the files I have edited?
I am running
sudo docker run --rm -it -p "8000:8000" -v "/opt/stellar:/opt/stellar" --name stellar stellar/quickstart --testnet
And in /opt/stellar
on my machine (AWS EC2) I have files alredy there included an edited stellar-core.cfg file.
Sorry if this is the a bit confusing. I am trying to explain what I mean as best I can. Thanks for any help.
Upvotes: 0
Views: 767
Reputation: 8646
Strictly speaking, you are not talking about volumes
but about bind mounts
, unlike volumes
, they allow you specify location on host machine.
The answer to your question is following:
Bind mount always uses hosts content. If container had something in mounted folder, it will be overriden.
Whenever you modify your folder from container, the changes persist on host (unless you bind ion readonly mode - then your changes would be rejected)
Upvotes: 1
Reputation: 159171
If you run:
docker run -v /host/directory:/container/directory ...
Then whatever is in the host directory will always hide whatever was in the image on that path, and if the application in the container makes changes in /container/directory
, they will be reflected in the corresponding host directory.
If you update the image to have changes in the container directory, and you run the same docker run
command, the host directory will still hide the image’s contents, and you won’t see those changes in the re-run container.
Upvotes: 1