Docker Storage Operations: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 9: | Line 9: | ||
=Container-Generated Data Storage Operations= | =Container-Generated Data Storage Operations= | ||
If the container has volume mount points specified with [[Dockerfile#VOLUME|VOLUME]] in its original Dockerfile, those mount points must be bound to paths on the native host when the container is created. This is done with [[Docker_run#-v.2C_--volume|--v|--volume]] or [[Docker_run#--mount|--mount]] (recommended) command line options, as follows: | If the container has volume mount points specified with [[Dockerfile#VOLUME|VOLUME]] in its original Dockerfile, those mount points must be bound to paths on the native host when the container is created. This is done with [[Docker_run#-v.2C_--volume|--v|--volume]] or [[Docker_run#--mount|--mount]] (recommended) command line options, as follows. Note that the mount succeeds even if no [[Dockerfile#VOLUME|VOLUME]] is declared in Dockerfile: | ||
docker run ... --mount type=bind,src=<''native-host-path''>,dst=<''container-mount-point''> ... | docker run ... --mount type=bind,src=<''native-host-path''>,dst=<''container-mount-point''> ... |
Revision as of 03:52, 9 May 2018
Internal
Overview
Container-Generated Data Storage Operations
If the container has volume mount points specified with VOLUME in its original Dockerfile, those mount points must be bound to paths on the native host when the container is created. This is done with --v|--volume or --mount (recommended) command line options, as follows. Note that the mount succeeds even if no VOLUME is declared in Dockerfile:
docker run ... --mount type=bind,src=<native-host-path>,dst=<container-mount-point> ...
docker run ... --mount type=bind,src=/data-volumes/postgresql,dst=/var/lib/pgsql/data ...
docker run ... -v <native-host-path>:<container-mount-point> ...
When --mount with type=bind is used, the native-host-path must refer to an existing path on the host. The path will not be created if it does not exist, and the command will fail. Also, the mount point must have sufficient permissions. For more details on native host path permissions, see Native Host Path Permissions.