Mounting local volumes to docker container

Edited for clarity

I run the following run command

  • Launch Docker containers to handle HTTP requests
  • Docker: Find dockerfile of images
  • Why shouldn't I run multiple processes in a Docker container?
  • Vagrant docker provider: create and start vs run
  • Docker build: unable to fetch archives
  • Docker - docker-compose 'version' doesn't have any configuration options
  • docker run -d -P -v /users/username/app:/app contname
    

    This resulsts in the following when i inspect the container

    "HostConfig": {
            "Binds": [
                "/users/username/app:/app"
            ],
    
    "Volumes": {
            "/app": "/users/username/app",
            "/app": "/mnt/sda1/var/lib/docker/vfs/dir/214a16c3678f93cbadb7e7b7d56b5f26b66a34c6d9bb89ade23b16e386a12212"
        },
    

    But when i ssh into the container, i can see that app is empty.

    Is my assumption that there should be the files from my host machine correct?

  • how to deploy Kubernetes nginx controller with kubeadm (k8s 1.4)?
  • Starting jupyterhub with docker
  • Boot2Docker mount host volume to externalize data using Windows
  • How to tail docker into jq?
  • Docker CE on Mac OSX hanging on startup
  • Is it possible to use Docker 17.03 secrets in Drupal 8?
  • One Solution collect form web for “Mounting local volumes to docker container”

    Boot2docker automatically mounts your home directory into the virtualbox boot2docker VM not the container. You still need to add -v /users/username/app:/app to your docker run command.

    When you add the Volume command to your docker file you are declaring a volume to be created by the container. This volume is mounted at /var/lib/docker/volumes on the host VM. These volumes can only be shared by passing –volumes-from to the docker run command. When you pass the -v switch you creating a volume using a specified location on the host file system.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.