meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:docker:volumes [2019/04/04 08:42] – created niziaklinux:docker:volumes [2025/09/29 20:22] (current) niziak
Line 4: Line 4:
   Data volumes are designed to persist data, independent of the container’s life cycle. Docker therefore never automatically delete volumes when you remove a container, nor will it “garbage collect”     volumes that are no longer referenced by a container.   Data volumes are designed to persist data, independent of the container’s life cycle. Docker therefore never automatically delete volumes when you remove a container, nor will it “garbage collect”     volumes that are no longer referenced by a container.
   A Docker data volume persists after a container is deleted.   A Docker data volume persists after a container is deleted.
 +
  
 Volumes types: Volumes types:
-  * local storage (original image data located in specified directory  are copied to volume during creation) +  * Anonymous Volume: any volume without a source, docker will create this as a local volume with a long unique id, and it behaves as a named volume 
-  * bind-mounted host (original image data are **not copied**)+  * Named Volume - local storage (original image data located in specified directory are copied to volume during creation) 
 +    * **local** driver is using ''/var/lib/docker/volumes'' for storage 
 +    * original image data **is copied** if volume is empty.  
 +    * All UID/GIDs are correctly set 
 +    * user has to take care about free space at ''/var/lib/docker/volumes'' 
 +  * Host volume: bind-mounted host 
 +    * original image data are **not copied** 
 +    * fastest - no volume driver is used 
 +    * possible problem with UID/GID permisions 
 +    * volume can be created on any location (different discs, etc)
   * volume plugins   * volume plugins
  
 Move volume between discs: Move volume between discs:
 <code bash>rsync -aqxP jenkins1_jenkins_homeSNAP/ /mnt/NVMe/@jenkins1_jenkins_home</code> <code bash>rsync -aqxP jenkins1_jenkins_homeSNAP/ /mnt/NVMe/@jenkins1_jenkins_home</code>
 +
 +===== Named bind-mount volume =====
 +
 +Sometimes 3rd party script or compose depends on named volumes, but we want to put particular named volume on different (faster) drive.
 +
 +from cmdline:
 +<code bash>
 +docker volume create -d local -o type=none -o o=bind -o device=/mnt/ssd/pgsql pgsql-data
 +</code>
 +
 +od compose file:
 +<code yaml>
 +volumes:
 +  pgsql-data:
 +    driver: local
 +    driver_opts:
 +      type: none
 +      o: bind
 +      device: /mnt/ssd/pgsql
 +</code>
 +
  
 ===== BTRFS Volume plugin for Docker ===== ===== BTRFS Volume plugin for Docker =====