Development Workflow
Bind mounts let you see code changes instantly.
bash
1# Mount source code
2docker run -v $(pwd):/app -p 3000:3000 myappRails Development
bash
1docker run -it --rm \
2 -v $(pwd):/app \
3 -v bundle-cache:/usr/local/bundle \
4 -p 3000:3000 \
5 ruby:3.2 \
6 bash -c "cd /app && bundle install && rails server -b 0.0.0.0"Node.js Development
bash
1docker run -it --rm \
2 -v $(pwd):/app \
3 -v /app/node_modules \
4 -p 3000:3000 \
5 node:18 \
6 npm run devNote: -v /app/node_modules creates anonymous volume to preserve container's node_modules.
File Permissions
bash
1# Run as current user
2docker run -u $(id -u):$(id -g) -v $(pwd):/app myappDocker Compose Example
yaml
1services:
2 app:
3 build: .
4 volumes:
5 - .:/app
6 - bundle-cache:/usr/local/bundle
7 ports:
8 - "3000:3000"
9
10volumes:
11 bundle-cache: