4 ms·
For me this falls down because my next questions is "cool, so I can run a database in a docker. So my data is save inside the docker?" Which it isn't, and I st
by legostormtroopr 9y ago
For me this falls down because my next questions is "cool, so I can run a database in a docker. So my data is save inside the docker?"
Which it isn't, and I still don't know how to attach permanent storage to a docker (if thats even the right term).
- TheCoelacanth 9y agoWhat you want is called a "volume". When running a docker container you just pass in the -v option and it maps a directory outside the container to a path that can be used from inside the docker container, e.g. `docker run -v /host/directory:/container/directory ...` would make the directory /host/directory on the host machine accessible inside the container at the path /container/directory. https://docs.docker.com/engine/admin/volumes/volumes/ https://docs.docker.com/engine/admin/volumes/volumes/
- 0xFORDCOMMA 9y agoWhile you can directly map the host filesystem to the container filesystem in the manner you describe, that's referred to as a bind mount, not a volume. Volumes reside in the host filesystem as well but are solely managed by Docker. Outside of trickery requiring the use of bind mounts (I use one to share ~/.ssh between a host user and container user, for example), volumes are recommended.