This is working exactly as expected.
__DIR__
is meant to return the absolute directory path of the currently running script.
Laradock makes use of bind mounts to mount your "app code path" (/Users/paul/Sites/ProjectX
) on the host machine into the docker container at this "app code path" (/var/www/ProjectX
). This allows you to preview your app code changes immediately rather than having to copy over source code on each change/edit.
docker-compose.yml
# ...
workspace:
build:
context: ./workspace
args:
# ...
volumes:
- ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
With that in mind, it's evident that the two environments have separate file systems.
When you make an HTTP request in your browser on the host machine, that HTTP request will be "forwarded" to a docker container listening on that specific port. I.e:
# ...
ports:
- "${APACHE_HOST_HTTP_PORT}:80"
- "${APACHE_HOST_HTTPS_PORT}:443"
# ...
Understanding that your HTTP request will be handled by a particular docker container (i.e. Apache/Nginx) rather than the host machine, performing an echo __DIR__;
will result in a script's absolute mounted directory path based on the docker container's file system.