github.com/moby/docker@v26.1.3+incompatible/api/types/mount/mount.go (about)

     1  package mount // import "github.com/docker/docker/api/types/mount"
     2  
     3  import (
     4  	"os"
     5  )
     6  
     7  // Type represents the type of a mount.
     8  type Type string
     9  
    10  // Type constants
    11  const (
    12  	// TypeBind is the type for mounting host dir
    13  	TypeBind Type = "bind"
    14  	// TypeVolume is the type for remote storage volumes
    15  	TypeVolume Type = "volume"
    16  	// TypeTmpfs is the type for mounting tmpfs
    17  	TypeTmpfs Type = "tmpfs"
    18  	// TypeNamedPipe is the type for mounting Windows named pipes
    19  	TypeNamedPipe Type = "npipe"
    20  	// TypeCluster is the type for Swarm Cluster Volumes.
    21  	TypeCluster Type = "cluster"
    22  )
    23  
    24  // Mount represents a mount (volume).
    25  type Mount struct {
    26  	Type Type `json:",omitempty"`
    27  	// Source specifies the name of the mount. Depending on mount type, this
    28  	// may be a volume name or a host path, or even ignored.
    29  	// Source is not supported for tmpfs (must be an empty value)
    30  	Source      string      `json:",omitempty"`
    31  	Target      string      `json:",omitempty"`
    32  	ReadOnly    bool        `json:",omitempty"` // attempts recursive read-only if possible
    33  	Consistency Consistency `json:",omitempty"`
    34  
    35  	BindOptions    *BindOptions    `json:",omitempty"`
    36  	VolumeOptions  *VolumeOptions  `json:",omitempty"`
    37  	TmpfsOptions   *TmpfsOptions   `json:",omitempty"`
    38  	ClusterOptions *ClusterOptions `json:",omitempty"`
    39  }
    40  
    41  // Propagation represents the propagation of a mount.
    42  type Propagation string
    43  
    44  const (
    45  	// PropagationRPrivate RPRIVATE
    46  	PropagationRPrivate Propagation = "rprivate"
    47  	// PropagationPrivate PRIVATE
    48  	PropagationPrivate Propagation = "private"
    49  	// PropagationRShared RSHARED
    50  	PropagationRShared Propagation = "rshared"
    51  	// PropagationShared SHARED
    52  	PropagationShared Propagation = "shared"
    53  	// PropagationRSlave RSLAVE
    54  	PropagationRSlave Propagation = "rslave"
    55  	// PropagationSlave SLAVE
    56  	PropagationSlave Propagation = "slave"
    57  )
    58  
    59  // Propagations is the list of all valid mount propagations
    60  var Propagations = []Propagation{
    61  	PropagationRPrivate,
    62  	PropagationPrivate,
    63  	PropagationRShared,
    64  	PropagationShared,
    65  	PropagationRSlave,
    66  	PropagationSlave,
    67  }
    68  
    69  // Consistency represents the consistency requirements of a mount.
    70  type Consistency string
    71  
    72  const (
    73  	// ConsistencyFull guarantees bind mount-like consistency
    74  	ConsistencyFull Consistency = "consistent"
    75  	// ConsistencyCached mounts can cache read data and FS structure
    76  	ConsistencyCached Consistency = "cached"
    77  	// ConsistencyDelegated mounts can cache read and written data and structure
    78  	ConsistencyDelegated Consistency = "delegated"
    79  	// ConsistencyDefault provides "consistent" behavior unless overridden
    80  	ConsistencyDefault Consistency = "default"
    81  )
    82  
    83  // BindOptions defines options specific to mounts of type "bind".
    84  type BindOptions struct {
    85  	Propagation      Propagation `json:",omitempty"`
    86  	NonRecursive     bool        `json:",omitempty"`
    87  	CreateMountpoint bool        `json:",omitempty"`
    88  	// ReadOnlyNonRecursive makes the mount non-recursively read-only, but still leaves the mount recursive
    89  	// (unless NonRecursive is set to true in conjunction).
    90  	ReadOnlyNonRecursive bool `json:",omitempty"`
    91  	// ReadOnlyForceRecursive raises an error if the mount cannot be made recursively read-only.
    92  	ReadOnlyForceRecursive bool `json:",omitempty"`
    93  }
    94  
    95  // VolumeOptions represents the options for a mount of type volume.
    96  type VolumeOptions struct {
    97  	NoCopy       bool              `json:",omitempty"`
    98  	Labels       map[string]string `json:",omitempty"`
    99  	Subpath      string            `json:",omitempty"`
   100  	DriverConfig *Driver           `json:",omitempty"`
   101  }
   102  
   103  // Driver represents a volume driver.
   104  type Driver struct {
   105  	Name    string            `json:",omitempty"`
   106  	Options map[string]string `json:",omitempty"`
   107  }
   108  
   109  // TmpfsOptions defines options specific to mounts of type "tmpfs".
   110  type TmpfsOptions struct {
   111  	// Size sets the size of the tmpfs, in bytes.
   112  	//
   113  	// This will be converted to an operating system specific value
   114  	// depending on the host. For example, on linux, it will be converted to
   115  	// use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
   116  	// docker, uses a straight byte value.
   117  	//
   118  	// Percentages are not supported.
   119  	SizeBytes int64 `json:",omitempty"`
   120  	// Mode of the tmpfs upon creation
   121  	Mode os.FileMode `json:",omitempty"`
   122  
   123  	// TODO(stevvooe): There are several more tmpfs flags, specified in the
   124  	// daemon, that are accepted. Only the most basic are added for now.
   125  	//
   126  	// From https://github.com/moby/sys/blob/mount/v0.1.1/mount/flags.go#L47-L56
   127  	//
   128  	// var validFlags = map[string]bool{
   129  	// 	"":          true,
   130  	// 	"size":      true, X
   131  	// 	"mode":      true, X
   132  	// 	"uid":       true,
   133  	// 	"gid":       true,
   134  	// 	"nr_inodes": true,
   135  	// 	"nr_blocks": true,
   136  	// 	"mpol":      true,
   137  	// }
   138  	//
   139  	// Some of these may be straightforward to add, but others, such as
   140  	// uid/gid have implications in a clustered system.
   141  }
   142  
   143  // ClusterOptions specifies options for a Cluster volume.
   144  type ClusterOptions struct {
   145  	// intentionally empty
   146  }