I’m trying to build a Rails container, but exclude the “.bundle” directory when the volume is mounted. Locally I have this content
$ cat .bundle/config
---
BUNDLE_JOBS: "4"
BUNDLE_BUILD__MYSQL2: "-- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
So in my docker-compose.yml file, I set it up like so
version: '3.3'
services:
…
web:
restart: "no"
build: ../web
ports:
- "3000:3000"
…
volumes:
- ../web/:/app
- /app/.bundle/
However, when I rebuild all my containers (docker-compose down —rmi all) and then bring everything back up (docker-compose up), the file is appearing within my docker container
$ docker exec -it c363429babe4 bash
root@c363429babe4:/app# cat /app/.bundle/config
---
BUNDLE_JOBS: "4"
BUNDLE_BUILD__MYSQL2: "-- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
What’s the proper way to exclude a directory when mounting a volume in Docker?