0

I was reading this questions How to copy files from host to Docker container?, Docker: Copying files from Docker container to host, and How to mount a host directory in a Docker container

Suppose those files are in Host

Directory: /home/user_host/

FileInHostOnly.zip
FileInHostAndContainer_1.zip suppose 15M, 2020/06/09  <- Older compared with Container
FileInHostAndContainer_2.zip suppose 15M, 2021/01/09  <- Newer compared with Container

Suppose those files are in Container

Directory: /home/user_cont/

FileInContainerOnly.zip
FileInHostAndContainer_1.zip suppose 12M, 2021/01/09  <- Newer compared with Host
FileInHostAndContainer_2.zip suppose 12M, 2019/12/09  <- Older compared with Host

Now the container starts..

docker run -v /home/user_host/:/home/user_cont/ --name myContainer the_image
  • How must solve the conflict?
  • After the myContainer finished, what would be the final result in the Host?

EDIT 1 (according to David-Maze response)

Merging in the directory context, some files are replaced others remains equal... At the Container and the Host will appear something like:

FileInHostOnly.zip, 
FileInContainerOnly.zip
FileInHostAndContainer_1.zip suppose 15M, 2020/06/09
FileInHostAndContainer_2.zip suppose 15M, 2021/01/09
QA_Col
  • 1,095
  • 9
  • 23

1 Answers1

0

There's no "conflict" here. With that docker run option, that host directory completely replaces the image directory, and reads and writes to that directory are visible on the host. You'd see, read, and write the larger versions of the files; there is no "merging" and there is no way to access the smaller versions of the files in the image.

David Maze
  • 94,671
  • 18
  • 109
  • 144
  • the `FileInContainerOnly.zip` file will disappear? – QA_Col Jun 10 '21 at 12:18
  • Yes. (This is the source of some Node-related issues, where a source tree without a `node_modules` directory is bind-mounted over the entire application installation tree and hides the results of a `RUN npm install` step, for example.) – David Maze Jun 10 '21 at 14:11