Class Mounts

java.lang.Object
io.github.pgatzka.docker.dsl.Mounts

public class Mounts extends Object
Mutable builder for a container's volume and bind mounts. Configured inside a container spec via mounts { volume(...); bind(...) } and flushed into immutable snapshots at task time.
  • Constructor Details

    • Mounts

      public Mounts()
      Default constructor for use by ContainerSpec; not intended for direct use.
  • Method Details

    • volume

      public void volume(String volumeName, String containerPath)
      Register a read-write named-volume mount.
      Parameters:
      volumeName - name of a volume declared in docker.volumes
      containerPath - absolute path inside the container
    • volume

      public void volume(String volumeName, String containerPath, boolean readOnly)
      Register a named-volume mount.
      Parameters:
      volumeName - name of a volume declared in docker.volumes
      containerPath - absolute path inside the container
      readOnly - true to mount read-only
    • bind

      public void bind(String hostPath, String containerPath)
      Register a read-write host bind mount.
      Parameters:
      hostPath - absolute or project-relative path on the host
      containerPath - absolute path inside the container
    • bind

      public void bind(String hostPath, String containerPath, boolean readOnly)
      Register a host bind mount.
      Parameters:
      hostPath - absolute or project-relative path on the host
      containerPath - absolute path inside the container
      readOnly - true to mount read-only
    • volumes

      public List<VolumeMount> volumes()
      Snapshot the registered volume mounts.
      Returns:
      an immutable snapshot of currently-registered volume mounts
    • binds

      public List<BindMount> binds()
      Snapshot the registered bind mounts.
      Returns:
      an immutable snapshot of currently-registered bind mounts
    • referencedVolumeNames

      public List<String> referencedVolumeNames()
      Names of the volumes referenced by registered volume mounts, in declaration order. Useful for cross-checking against docker.volumes.
      Returns:
      referenced volume names