How to mount ColdFusion volume in Docker?

865 Views Asked by At

Here is the docker-compose file I tried for ColdFusion 2018,

version: '3.3'
services:
cf18:
  environment:
    - acceptEULA=YES
    - password=admin
  volumes:
    - /opt/coldfusion/:/opt/coldfusion/
  ports:
    - 8500:8500
  image: adobecoldfusion/coldfusion2018:latest
  command: 'whoami'

It works but the volumes could not be mounted and I have a docker error log like below,

/opt/startup/start-coldfusion.sh: 523: cd: can't cd to /opt/coldfusion/cfusion/bin/

I need to mount this because the changes need to persist when I do Docker "docker-compose down" and "docker-compose up".

Any help would be greatly appreciated.

2

There are 2 best solutions below

1
Adrian J. Moreno On

I found this repo of ColdFusion Docker Images, maintained by none other than Charlie Arehart:

https://github.com/carehart/awesome-cf-compose

Digging into this one shows the mount point for /app located in the repo's folder structure.

# Project structure:

.
├── docker-compose.yml
├── app
    └── test.cfm
    └── dumpserver.cfm

# docker-compose.yml

services:
    coldfusion: 
        image: adobecoldfusion/coldfusion2021:latest
        ports:
        - "8500:8500"
        environment:
            - acceptEULA=YES
            - password=123
        volumes:
            - ./app:/app
0
Dan S On

You shouldn't mount the entire /opt/coldfusion folder to your host system. Only mount the sub-folders that you want to persist (like logs, etc). Below is an example of this from my coldfusion-docker-starter repo (https://github.com/dskaggs/coldfusion-docker-starter):

services:
  coldfusion:
    image: eaps-docker-coldfusion.bintray.io/cf/coldfusion:latest
    env_file: coldfusion.env
    ports:
    - 8500:8500
    - 5005:5005
    volumes:
    - ${PWD}/app:/app
    - ${PWD}/logs/:/opt/coldfusion/cfusion/logs/
    networks: 
      - web

networks:
  web:  

Bind mounts do not have to be limited to directories either. You can mount a specific file from the host to a file in the container as well. For example, this is one way to mount the MySQL driver JAR files into the container so that ColdFusion can access them (I wouldn't do this on production, just providing an example):

volumes:
- ${PWD}/app:/app   
- ${PWD}/data/:/data
- ${PWD}/drivers/mysql-connector-java-8.0.21.jar:/opt/ColdFusion/cfusion/lib/mysql-connector-java-8.0.21.jar

Edit: fixed indentation