Admin User     Jul,14 2017

Deploying Lucee on Docker

Finally, decided to play with Docker and Lucee for one of our project which we are trying to move eventually in Linux platform and believe me it was fun.

Here are steps to getting started with Lucee, Docker and Window 10. 

Download dockers windows version from https://www.docker.com/docker-windows and install it by following the user-friendly wizard. Once installed you should see Docker icon loaded with containers

lucee

To check out Docker is installed correctly and running open up powershell and run following command.

And you should see similar to below output, probably your version is newer than mine.

Docker version 17.03.1-ce, build c6d412e

Now it is time to pull lucee image into Docker, for this blog I am pulling Lucee 5.2 on Tomcat 8-jre 8 with Nginx (https://github.com/lucee/lucee-dockerfiles/tree/master/lucee-nginx/5.2) with the latest version. 

The following command will pull latest tagged docker image.

once pull completed you can confirm it by listing all docker images by using ``` docker images``` command and you should see lucee/lucee52-nginx in your list.

Lucee docker image by default configured to run with a single website for location /var/www and containing "Hello World" kind of index.cfm within it. You may want to go through read me file available on (https://github.com/lucee/lucee-dockerfiles/tree/master/lucee-nginx/5.2) to know all configuration.

Now it's time to run container, use the following command.

Voila, it's running. In browser hit http://localhost:81 (yes 81) and you should see "Hello World" output. In my case, I have trying exposed port 80 to 81 of host system since 80 was already occupied by my IIS web server. In a case of port 80 is open in your host file there is no need of supplying '-p' and it will run on port 80.

Instead of using single CFML page I wanted to have my own project to deploy on Docker container, you may copy files to /var/www and should work fine but remember you may require to commit your container changes to existing image or newer one and doing this every time whenever we change code is a headache. And this can be resolved by mapping local drive with docker. 

In Docker setting, choose the option "Shared Drives" and check drive which contains your CFML project.

Once you shared your drive you may need to rerun your docker container with the following command.

Basically, we have mounted our c:/project1 with /var/www and this will overwrite your /var/www folder with your c:/project1. This way you may not require building your image every time you change the code. Finally, my code is running via Docker but wait how do I add my datasource and other web admin setting. No, http://localhost:81/lucee/admin/web.cfm won't work as by default in Nginx it configured block admin request so that URL will give 403 error. Even after changing Nginx configuration to allow requests for lucee admin it didn't work for me, only change was it started showing 404 instead of 403. Probably still some configuration issue. Thought I don't want to keep web admin open on port 80 in production server I left is as it is but export port 8888 which will bypass Nginx and talk with Tomcat and in production, I can also put that specific port behind a firewall to restrict. 

Finally, run below command,

and you should able to view web admin via http://localhost:8282/lucee/admin/web.cfm. 

And, my Lucee under docker up and running. You may make configuration changes via web admin but keep in mind that changes you are doing in a container, not in Image. You may require committing a change in image and I preferred as separate from lucee/lucee52-nginx. Using 'docker ps' command get container id (in my case it was 2423e10c1d06). 

will create another image with all my recent changes. 

and then use 

the command to run every time you want to work on a project.

In case you want access shell prompt to change any configuration file, after running your container execute below command to get shell prompt.

After changing any setting don't forget to commit your changes on image otherwise you loose all changes once container stopped.

PS: Probably whatever method I have suggested may not be the best way to do it. I have started playing with docker from last two days and I have built based on whatever issue I have faced.