How to share data between the docker container and the host?

I tried to share data between the docker container and the host, for example by adding the parameter -v /Users/name/Desktop/Tutorials:/cntk/Tutorials to the docker run command, but I noticed that it also deletes all the files on the docker contained in /cntk/Tutorials.

My question is how to make the same link, but having instead all the files in /cntk/Tutorials copied to the host (at /Users/name/Desktop/Tutorials)

  • Are Windows Containers unavailable on Windows 10 Education?
  • Deleting files inside docker container not freeing up space on host system
  • Copy apps on docker jboss/wildfly images container
  • how does Flocker implement image migration while doing container migration between hosts
  • Windows 10 Docker Host - Display GUI application from Linux Container
  • Docker running on Centos7 with a Windows 7 container
  • Thank you

  • Getting java.lang.OutOfMemoryError thrown at me when running Spark inside Docker
  • Is it possible to start a shell session in a running container (without ssh)
  • Cannot browse dockerized web app from other computers on network
  • How to fix this issue “no suitable node (scheduling constraints not satisfied on 1 node)” in docker swarm while deploying registry?
  • Kubernetes how to run container only after volume(nfs) is mounted
  • Docker on a Server 2016 Virtual Machine
  • 2 Solutions collect form web for “How to share data between the docker container and the host?”

    Unfortunately that it is not possible, take a look here. That is because this is how mounting works in Linux.

    It is not correct to say that the files were deleted. They are still present in the underlying image, but the act of mounting another directory at the same path has obscured them. They exist, but are not accessible in this condition.

    One way you can accomplish this is by mounting a volume into your container at a different path, and then copying the container’s files to that path. Something like this.

    Mount a host volume using a different path than the one the container already has for the files you are interested in.

    docker run -v /Users/name/Desktop/Tutorials:/cntk/Tutorials2 [...]

    Now, execute a command that will copy the files already in the docker image, into the mounted volume from the outside host.

    docker exec <container-id> cp -r /cntk/Tutorials /cntk/Tutorials2
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.