docker container: add symlink to /Users/www/[project] in /var/www to access and serve local files

803 views Asked by At

I am trying to serve local CFML files on my mac via the Lucee docker container (https://hub.docker.com/r/lucee/lucee5/). I got so far as to mount the specific folder on my mac to a symlink within my docker images docker run -it imagename -v /Users/[username]/www/projectx:/code /bin/bash So on the bash in the docker image I now have /code. I then create a symlink ln -s /code projectx in my /var/www.

When I then serve the image running tomcat whilst also mounting the the folder

docker run -p 1337:8888 -v /Users/[username]/www/projectx:/code [imagename] catalina.sh run

I would expect to be able to access http://localhost:1337/projectx Unfortunately it can't find that folder. Probably since Lucee doesn't recognises or indexes the the files on run time?

Is this possible?

The outcome I am look at is developing my Coldfusion app on my MAC while running Lucee+mysql on my docker container and having the source code locally so that I don't have to play with samba shares or other ways to be able to edit the coldfusion files in my IDE. (Samba share stopped working when I upgraded to Sierra)

2

There are 2 answers

5
Simon at The Access Group On BEST ANSWER

Have you considered simply mounting the code directory onto /var/www, which is the default VOLUME mount point in the Lucee Docker image? If you really want it to be in a /code subdirectory, then have that subdirectory on your host instead of playing with symlinks.

An easy way to do this is using docker-compose, for example the following docker-compose.yml

version: '2'

services:
  web:
    image: lucee/lucee5
    ports:
      - "1337:8888"
    volumes:
      - /Users/[username]/www/projectx:/var/www

You can then run this by using docker-compose up

2
Ehud Kaldor On

Unless there is a need to have the content of /code change during the lifetime of the container, you can just COPY or ADD it during the container build. if not, as Simon suggested above, it makes more sense to mount the volume directly where you want to use it. make it RO if you don't want the container to change anything in the volume.