dockerized Node.js application that I've developed holds the pb_migrations directory. In below Docker Compose document you can see that it depends on dockerized version of PocketBase.
What I want to achieve is that the PB container upon start should have the /app/pb_migrations directory from node container available on its /pb_migrations path.
I have tried to use named volume to do so, but the directory is empty for PB container. I don't want to copy the directory separately every time and mount it from the host, and would love to just use the docker-compose.yml document to run it.
version: '3.7'
services:
pocketbase:
image: spectado/pocketbase:0.19.2
container_name: pocketbase
restart: unless-stopped
ports:
- '8090:80'
volumes:
- pb_data:/pb_data
- pb_migrations:/pb_migrations/
app:
image: app:latest
container_name: app
restart: unless-stopped
env_file: .env
volumes:
- pb_migrations:/app/pb_migrations/
ports:
- '$PORT:$PORT'
depends_on:
- pocketbase
volumes:
pb_data:
pb_migrations:
to make the
/app/pb_migrationsdir from the app container available at the/pb_migrationspath in thepocketbasecontainer using Docker Compose, you can use a bind mount. Bind mounts let you directly connect a directory from one place, like the host or another container, into another container.https://docs.docker.com/compose/compose-file/compose-file-v3/#volumes
you can checkout this answer