Docker - Data Persistence


mount a file or directory of the host into a container.

Bind mounts and volumes can both mounted into containers using the -v or –volume flag.

From your machine to the container

If you want to have the files of your machine on the host, you need to mount them on the host. See Shared drive configuration on Virtual Box

You can also use:

  • the cp command to transfer file between your local file system and the container
  • from the host: vim scp:[email protected]path/to/document

Bind Mount vs Volume

Bind mounts have limited functionality compared to volume. By contrast, when you use a volume, a new directory is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.

Powered by ComboStrap