25491

Docker osx mounted folder is empty

Question:

I tried to mount folder of my project from /var/www to the same folder in container but folder in container is empty. Problem is maybe with host folder permissions because if i try that with some other folder it works.

This works:

docker run -it -v ~/Downloads:/var/www debian:jessie /bin/bash

This doesn't work:

docker run -it -v /var/www:/var/www debian:jessie /bin/bash

Answer1:

You cannot mount any folders outside your homedir ~/, this is the VM restriction on Mac and Windows. When the Virtualbox is created it mounts the folders within your Users directory, which makes it the only folder available to the containers <a href="https://github.com/docker/kitematic/issues/1192" rel="nofollow">https://github.com/docker/kitematic/issues/1192</a>

By default, Machine will only share your home directory. If you want to add more, you need to add them using the VirtualBox UI. <a href="https://github.com/docker/machine/issues/1814" rel="nofollow">https://github.com/docker/machine/issues/1814</a>

Answer2:

In addition to vitr's great answer above, if you are using <a href="https://github.com/codekitchen/dinghy" rel="nofollow">Dinghy</a> with your docker containers, then on your local machine check the setting of <strong>DINGHY_HOST_MOUNT_DIR</strong> and <strong>DINGHY_GUEST_MOUNT_DIR</strong> <em>that the folder you are trying to mount is below what is specified</em> in the above environment variables. If those env. vars are not specified then your home directory is assumed.

$ env | grep DINGHY_HOST_MOUNT_DIR DINGHY_HOST_MOUNT_DIR=/Users/ro/my_docker_workspace $ env | grep DINGHY_GUEST_MOUNT_DIR DINGHY_GUEST_MOUNT_DIR=/Users/ro/my_docker_workspace

So in the case above, I can only mount local folders in my_docker_workspace and below.

Recommend

  • LDAPSEARCH into table format
  • Objective-C, How to properly encode hex to image file?
  • Using variable in default filter in Ansible Jinja2 template
  • Android: isDirectory() always returning true
  • finishActivity() - closing all activities with exact request code
  • file_get_contents(): open_basedir restriction in effect
  • Java Socket Reuse
  • Is there a limit on how long a cfquery with cfqueryparam can get?
  • Implementing HMAC-SHA256 for Keybase in Javascript
  • Objective C - Create a framework for my iphone apps?
  • Git cleanup/garbage collection on remote VSO git repository
  • Getting zero results in search using elastic4s
  • RPMs for IDAS IoTAgents GE, from Fiware
  • Visual Studio - PathTooLongException even when the path length is less than 260 characters
  • Which browser have this strange user agent? (IOS device)
  • Generic classes with Collection getter of other types
  • How can I get the full list of running processes on a Mac from a python app
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • Unexpected token ILLEGAL while running node.js mocha test
  • Get specific string
  • cygwin cannot exec 'git-add--interactive' permission denied
  • MS Access - How to change the linked table path by amend the table
  • Ajax calls do not work in IE unless you fiddle with security settings
  • Install PHP intl extension on MacOS
  • Alternative to overridePendingTransition() - Android
  • Rails Find when some params will be blank
  • MongoError: Incorrect arguments
  • C++ Partial template specialization - design simplification
  • Change Inet root folder for iis 7
  • Pass value from viewmodel to script in zk
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • Cassandra Data Model
  • Updated Ionic CLI but shows previous version (Windows)
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Error creating VM instance in Google Compute Engine
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • How to load view controller without button in storyboard?