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)

  • Docker and Kubernetes repository for linux
  • Docker RabbitMQ persistency
  • IBM Bluemix keeps asking for credentials
  • How to mount a docker volume while using a windows host?
  • Kubernetes and ERR_CONNECTION_RESET
  • Docker container from image created by build: is working but not working from pulled image
  • Thank you

  • Docker container cannot clone public Github repo
  • Docker-compose up creates container but coudn't start it
  • Docker image wrapping for binary blobs
  • How to efficiently get info from all Docker containers running on a server via SSH?
  • docker-compose removing shared volume
  • Docker Golang onbuild custom action at docker run
  • 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.