Skip to content

Instantly share code, notes, and snippets.

@shmup
Created January 11, 2025 21:08
Show Gist options
  • Save shmup/d7e071927e6b740b6191b381d1120d87 to your computer and use it in GitHub Desktop.
Save shmup/d7e071927e6b740b6191b381d1120d87 to your computer and use it in GitHub Desktop.
volume mounts
# simple bind mount - directly maps host directory to container
# pro: simple, direct
# con: less docker-native management
volumes:
- /opt/medusa/postgres:/var/lib/postgresql/data
# named volume with bind properties - docker managed but host-accessible
# pro: docker volume features (named reference, metadata, drivers)
# con: more verbose, possibly overengineered for simple needs
volumes:
postgres_data:
driver: local
driver_opts:
type: none # disables storage driver features
o: bind # makes it act like bind mount
device: /opt/medusa/postgres # host path
# relative path bind mount - maps directory relative to docker-compose.yml
# pro: portable across machines, stays with project
# con: must run docker-compose from correct directory
volumes:
- ./postgres:/var/lib/postgresql/data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment