I am attempting to mount a file (nginx.conf) in the volumes section of my docker-compose.yml. I can mount a directory as a volume without issue, however, it is not clear to me what the syntax is for a file.
I have the following defined in my volumes section
volumes:
roundcubeweb:
driver: local
driver_opts:
type: none
o: bind
device: /mnt/docker/volumes/roundcube/html
nginxconf:
driver: local
driver_opts:
type: none
o: bind
device: /mnt/docker/volumes/roundcube/nginx.conf
Later on, I have the following under my services section
nginx:
image: nginx:latest
deploy:
replicas: 1
restart: always
depends_on:
- roundcube
ports:
- "8082:80"
volumes:
- roundcubeweb:/var/www/html
- nginxconf:/etc/nginx/conf.d/default.conf
When I attempt to start this up, I receive the following error:
ERROR: for roundcube_nginx_1 Cannot create container for service nginx: failed to mount local volume: mount /mnt/docker /volumes/roundcube/nginx.conf:/var/lib/docker/volumes/roundcube_nginxconf/_data, flags: 0x1000: not a directory
ERROR: for nginx Cannot create container for service nginx: failed to mount local volume: mount /mnt/docker/volumes/rou ndcube/nginx.conf:/var/lib/docker/volumes/roundcube_nginxconf/_data, flags: 0x1000: not a directory ERROR: Encountered errors while bringing up the project.
I've found that if I inline the file location in the nginx service section's volume declaration then it works just fine. For example:
volumes:
- roundcubeweb:/var/www/html
- /mnt/docker/volumes/roundcube/nginx.conf:/etc/nginx/conf.d/default.conf
Can one not mount a file in the volumes section? Is there a reference for the local driver's parameters?