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)

  • What's inside a Docker image/container?
  • Virtualbox inside Docker
  • Jobs scheduling in Google Container Engine (Kubernetes)
  • Cant produce-to OR consume-from kafka broker running inside a container
  • Mapping exposed ports on Bluemix containers
  • dokku - where is my application's directory
  • Thank you

  • DockerHub set tag alias in automated build
  • Docker-Compose POSTGRES script only creates db not table
  • Dockerfile dosen't work on Google managed Virtual Machine
  • How do I execute commands on Karaf running inside Docker?
  • How to upgrade Openshift Origin Docker to latest version?
  • Install nodejs using docker
  • 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.