Back to questionsHow do the two
JuniorTheoryVery common
How do the two -v mounts in these commands differ?
docker run -d -e POSTGRES_PASSWORD=secret -v pgdata:/var/lib/postgresql/data postgres:17
docker run -d -v "$(pwd)/site":/usr/share/nginx/html nginx:1.27.3pgdata is a named volume: Docker creates it and keeps it in its own storage area. $(pwd)/site is a bind mount: that host folder appears in the container as it is, and you manage its files.
- Reading
pgdata:as a relative folder rather than a volume name - Expecting a named volume to vanish together with its container
- Which command shows where Docker keeps the
pgdatavolume? - Why is a bind mount handy in development but a volume preferred for a database?