Hi,
I'm using devilbox on MacOs 10.10.5 + Docker 17.06.0-ce for Mac + docker-compose 1.14.0
While docker doc ( https://docs.docker.com/docker-for-mac/osxfs/#namespaces ) states that /Volumes/... is available in containers, when I run devilbox ./bash.sh I do not see /Volumes (nor /Users /private).
This prevent usage of symlinks under ./data/www/my-project
ln -s /Volumes/repo/gitRepoOfMyCode/www htdocs
once into php container this link is broken
What I did to solve this issue:
A) in .env, I add:
HOST_PATH_HTTPD_SYMLINK=/Volumes/repo
B) in docker.compose.yml, I add those 2 lines:
# Mount volumes related to ln -s htdocs
- ${HOST_PATH_HTTPD_SYMLINK}:${HOST_PATH_HTTPD_SYMLINK}:cached
under those two sections:
httpd.volumes and php.volumes (in addition to the ${HOST_PATH_HTTPD_DATADIR} usage )
It works now :)
I am not proud of this duplicate into docker.compose.yml and even worse having modified this file but it is the only easy way I found using ln -s for htdocs when project code is on a separate volume.
Maybe I should use docker.compose.yml volumes like suggested by https://www.baptiste-donaux.fr/tutoriel-symfony-docker-compose-v2/ but this is my very first Docker usage... up to you to decide :)
Note: I did try first setting HOST_PATH_HTTPD_DATADIR to /Volumes/repo/gitRepoOfMyCode (instead of ./data/www) but since /Volumes is not mounted in the container, this does not help.
Hi @normance,
thanks for the detailed description.
I am currently not on a Mac, but I remember, that you have to explicitly allow directories outside your home dir to be mounted in the Docker settings itself. I think it defaults to your user's home dir. Could you check that please.
This is where you need to specify your volumes/directories that are allowed to be mounted:
Thanks for the quick reply :)
You are right, the Docker doc says so.
The file sharing option list 4 directories (/Users, /Volumes, /tmp, /private) that can be easily mounted but I do not have access to the commande line:
docker run -v /Volumes/repo:/Volumes/repo:cached ...
since it is handled by devilbox; so I don't know how to configure this mounting elsewhere that in the docker.compose.yml
Note: I did try first setting HOST_PATH_HTTPD_DATADIR to /Volume/repo/gitRepoOfMyCode (instead of ./data/www) but since /Volumes is not mounted in the container, this does not help.
When you allowed /Volumes as a mountpoint in the Docker settings and have set HOST_PATH_HTTPD_DATADIR=/Volumes (in .env), it should be mounted as /shared/httpd.
Could you check on that please.
I have done a fresh install of both Docker for Mac and of your git repo
Into Docker for Mac, the ready to mount volumes are:

Into .env
### Local filesystem path to www projects.
###
#HOST_PATH_HTTPD_DATADIR=./data/www
HOST_PATH_HTTPD_DATADIR=/Volumes/repo/gitRepoOfMyCode
And the problem is fixed since I can see the content of gitRepoOfMyCode under /shared/httpd
Sorry for that ticket, but yesterday the behaviour was not that one. Fresh install helps sometime
BTW: thanks for Percona, it is the one I was expected but I did not want to bother you with that request
Cool. :-)
You should probably just use the upper folder for mounts:
HOST_PATH_HTTPD_DATADIR=/Volumes/repo/
If the repo directory contains multiple projects.
Btw, could I use your screenshot for documentation purposes?
yes this is what I have done, I get more ERR into http://127.0.0.1/vhosts.php since all repos does not have htdocs entry, but I can live with that :)
Please use the screenshot as you need
In my case, I often save my projects to /home/ngoclb/projects, so I create another environment variable called HOST_PATH_REAL_DATADIR and move to containers. It make htdocs can follow symlinks without get multiple ERR in http://localhost/vhosts.php
In .env:
HOST_PATH_HTTPD_DATADIR=./data/www
HOST_PATH_REAL_DATADIR=/home/ngoclb/projects
In docker-compose.yml:
... # line 184
# Mount custom mass virtual hosting
# (configured in /etc/${HTTPD_SERVER}/02-vhost-mass.conf)
- ${HOST_PATH_HTTPD_DATADIR}:/shared/httpd
- ${HOST_PATH_REAL_DATADIR}:${HOST_PATH_REAL_DATADIR}
...
# line 261
# Mount custom mass virtual hosting
# (configured in /etc/${HTTPD_SERVER}/02-vhost-mass.conf)
- ${HOST_PATH_HTTPD_DATADIR}:/shared/httpd:ro
- ${HOST_PATH_REAL_DATADIR}:${HOST_PATH_REAL_DATADIR}:ro
...
After restart container, docker can follow symlinks like this:
ngoclb at NgocLB-T440 in ~/devilbox/data/www/ngoclb
$ ls -la
total 8
drwxr-xr-x 2 ngoclb ngoclb 4096 Aug 12 17:51 .
drwxr-xr-x 3 ngoclb ngoclb 4096 Aug 12 17:47 ..
lrwxrwxrwx 1 ngoclb ngoclb 50 Aug 12 17:51 htdocs -> /home/ngoclb/projects/ngoclb.com/public_html
Hope this help !
@lbngoc
Thanks for the information. As you seem to be using Linux it should be much easier for you to accomplish the same:
In .env:
HOST_PATH_HTTPD_DATADIR=/home/ngoclb/projects
In your ngoclb project folder:
ngoclb at NgocLB-T440 in /home/ngoclb/projects/ngoclb
$ ls -la
total 8
drwxr-xr-x 2 ngoclb ngoclb 4096 Aug 12 17:51 .
drwxr-xr-x 3 ngoclb ngoclb 4096 Aug 12 17:47 ..
drwxr-xr-x 3 ngoclb ngoclb 4096 Aug 12 17:47 public_html
lrwxrwxrwx 1 ngoclb ngoclb 50 Aug 12 17:51 htdocs -> public_html
...
@cytopia
devilbox is actually good but I don't like use HOST_PATH_HTTPD_DATADIR inside my working space folder (projects), because it will scan all my children project folders and put multiple error on page http://localhost/vhosts.php
Example my data/www:
www
โโโ ngoclb
โย ย โโโ htdocs -> /home/ngoclb/projects/private/ngoclb.com/public_html
โโโ abc
โย ย โโโ htdocs -> /home/ngoclb/projects/working/abc/public_html
โโโ xyz
โย ย โโโ htdocs -> /home/ngoclb/projects/working/xyz/public_html
@lbngoc I see what you mean now. Still good solution you have provided.
That's a nice solution @lbngoc, but changing/editing the docker-compose.yml seems too radical IMO, if you need to update devilbox and such.
There's the possibility of using a docker-compose.override.yml with docker compose, that will override/add/augment config to the docker-compose.yml. Maybe we can add this docker-compose.override.yml to .gitignore and have that real data dir config cleanly separated from devilbox files?
Amazing, got a neat solution for this.
Just added my docker-compose.override.yml as such:
version: '2.1'
services:
php:
volumes:
- $HOME:$HOME
httpd:
volumes:
- $HOME:$HOME
... and now I can safely symlink to anything inside my home folder (if one needs to symlink outside home folder just adjust this as YMMV). Doing this now works:
./data/www/wp-sandbox $ ln -s ~/Documents/Code/wordpress-sandbox htdocs
๐ ๐
I'll add a PR adding docker-compose.override.yml to .gitignore.
Most helpful comment
Amazing, got a neat solution for this.
Just added my
docker-compose.override.ymlas such:... and now I can safely symlink to anything inside my home folder (if one needs to symlink outside home folder just adjust this as YMMV). Doing this now works:
๐ ๐
I'll add a PR adding
docker-compose.override.ymlto.gitignore.