I’ve been modernizing our development environment and started with the work by Bill Rawlinson to create a portable ColdFusion Docker image. If you’re new to Docker and the benefits of containerization, read up why Docker is dominating 2015. We have Docker Compose running a stack with ColdFusion, Nginx, Postgres, ActiveMQ and Redis all linked together and the entire setup can be started with one command:
docker-compose up -d
I’m simultaneously moving from a Windows machine to a Mac and I’ve been really missing the console logging for watching application activity and errors. It’s easy when installed locally to tail the coldfusion-out.log file but once containerized you don’t have that luxury (without using docker exec to log in to the running container which is a bad practice). The issue is on Linux, ColdFusion has no option to log to stdout like on Windows. As a result, the docker logs command can’t see the output from ColdFusion once the container is running.
It turns out there is a very simple and very elegant way to force ColdFusion, or any app which wants to daemonize and write to log files, to write to stdout. From this ServerFault thread referencing the Nginx Dockerfile, you can symlink the coldfusion-out.log file to /dev/stdout:
ln -sf /dev/stdout /opt/coldfusion10/cfusion/logs/coldfusion-out.log
My Dockerfile for ColdFusion has these two lines:
# redirect logs so `docker logs -f <container>` works
RUN ln -sf /dev/stdout /opt/coldfusion10/cfusion/logs/coldfusion-out.log
RUN ln -sf /dev/stderr /opt/coldfusion10/cfusion/logs/coldfusion-err.log
Now the logs can be collected and observed in a centralized location using Docker best practices.
Comments are closed.