Mounting directory from host machine to container in Docker

docker, dotcloud

Solution

Just as a final update, this feature is now released in Docker (though the API has changed since the pull request linked by @imiric).

Simply use a command like

docker run -v /tmp:/root myImage

in order to mount `/tmp` from the host machine as `/root` within the image.

Source: https://docs.docker.com/engine/userguide/dockervolumes/

Problem

How do I mount a directory from the host machine to a container in Docker?

Original source