Muhammad Umer
Muhammad Umer

Reputation: 18127

How to get data from docker container into shared folder at host?

i was able to mount volume between ~/share at my mac/host and opt/abc inside container. However upon doing so both appeared empty. Even though container had whole app in it. But it worked i created files and it showed up on both places.

What can i do to kind of fetch all file from the container and put it into the folder at the side of host/mac.

Again. It connects and sync on fine from point onward. But stuff already present there inside container isn't not showing up.

Upvotes: 1

Views: 675

Answers (1)

VonC
VonC

Reputation: 1327696

When you mount a host directory as a data volume:

If the path /opt/abc already exists inside the container’s image, the ~/share mount overlays but does not remove the pre-existing content.
Once the mount is removed, the content is accessible again. This is consistent with the expected behavior of the mount command.

"overlays but does not remove the pre-existing content" means the pre-existing content becomes invisible for the duration of the mount.

So for the container folder to appear empty is the expected behavior (when you mount over it an host folder initially empty)

how to get data into host from container.

You actually need the opposite: get that data on your host first, then launch your container and mount that host folder as a volume.

Upvotes: 2

Related Questions