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)

  • Can SSH in but not out of docker container: network unreachable
  • How to create a Docker container of an AngularJS app?
  • What is the “only” argument of pm2-docker for?
  • Performance of IBM Containers Volumes
  • Sonatype Nexus3 docker image - How to setup an internal docker repository
  • what is the <my_namespace> in the command ic build -t<my_namespace>/myimage
  • Thank you

  • In Docker, can I use the JSON format for entrypoint from the command line?
  • Remote Node.js typescript debugging in WebStorm
  • Pushing Docker Hub images to private Docker Registry
  • How to export Mongo-database using Docker?
  • Docker Google cloud
  • Unable to execute docker command while docker is running
  • 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.