docker: Index | Files

package mounts

import ""


Package Files

lcow_parser.go linux_parser.go mounts.go parser.go validate.go volume_copy.go volume_unix.go windows_parser.go


const (
    // OSLinux is the same as runtime.GOOS on linux
    OSLinux = "linux"
    // OSWindows is the same as runtime.GOOS on windows
    OSWindows = "windows"


var ErrVolumeTargetIsRoot = errors.New("invalid specification: destination can't be '/'")

ErrVolumeTargetIsRoot is returned when the target destination is root. It's used by both LCOW and Linux parsers.

type MountPoint Uses

type MountPoint struct {
    // Source is the source path of the mount.
    // E.g. `mount --bind /foo /bar`, `/foo` is the `Source`.
    Source string
    // Destination is the path relative to the container root (`/`) to the mount point
    // It is where the `Source` is mounted to
    Destination string
    // RW is set to true when the mountpoint should be mounted as read-write
    RW  bool
    // Name is the name reference to the underlying data defined by `Source`
    // e.g., the volume name
    Name string
    // Driver is the volume driver used to create the volume (if it is a volume)
    Driver string
    // Type of mount to use, see `Type<foo>` definitions in
    Type mounttypes.Type `json:",omitempty"`
    // Volume is the volume providing data to this mountpoint.
    // This is nil unless `Type` is set to `TypeVolume`
    Volume volume.Volume `json:"-"`

    // Mode is the comma separated list of options supplied by the user when creating
    // the bind/volume mount.
    // Note Mode is not used on Windows
    Mode string `json:"Relabel,omitempty"` // Originally field was `Relabel`"

    // Propagation describes how the mounts are propagated from the host into the
    // mount point, and vice-versa.
    // See
    // Note Propagation is not used on Windows
    Propagation mounttypes.Propagation `json:",omitempty"` // Mount propagation string

    // Specifies if data should be copied from the container before the first mount
    // Use a pointer here so we can tell if the user set this value explicitly
    // This allows us to error out when the user explicitly enabled copy but we can't copy due to the volume being populated
    CopyData bool `json:"-"`
    // ID is the opaque ID used to pass to the volume driver.
    // This should be set by calls to `Mount` and unset by calls to `Unmount`
    ID  string `json:",omitempty"`

    // Sepc is a copy of the API request that created this mount.
    Spec mounttypes.Mount

    // Some bind mounts should not be automatically created.
    // (Some are auto-created for backwards-compatibility)
    // This is checked on the API but setting this here prevents race conditions.
    // where a bind dir existed during validation was removed before reaching the setup code.
    SkipMountpointCreation bool
    // contains filtered or unexported fields

MountPoint is the intersection point between a volume and a container. It specifies which volume is to be used and where inside a container it should be mounted.

Note that this type is embedded in `container.Container` object and persisted to disk. Changes to this struct need to by synced with on disk state.

func (*MountPoint) Cleanup Uses

func (m *MountPoint) Cleanup() error

Cleanup frees resources used by the mountpoint

func (*MountPoint) Path Uses

func (m *MountPoint) Path() string

Path returns the path of a volume in a mount point.

func (*MountPoint) Setup Uses

func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.Identity, checkFun func(m *MountPoint) error) (path string, err error)

Setup sets up a mount point by either mounting the volume if it is configured, or creating the source directory if supplied. The, optional, checkFun parameter allows doing additional checking before creating the source directory on the host.

type Parser Uses

type Parser interface {
    ParseMountRaw(raw, volumeDriver string) (*MountPoint, error)
    ParseMountSpec(cfg mount.Mount) (*MountPoint, error)
    ParseVolumesFrom(spec string) (string, string, error)
    DefaultPropagationMode() mount.Propagation
    ConvertTmpfsOptions(opt *mount.TmpfsOptions, readOnly bool) (string, error)
    DefaultCopyMode() bool
    ValidateVolumeName(name string) error
    ReadWrite(mode string) bool
    IsBackwardCompatible(m *MountPoint) bool
    HasResource(m *MountPoint, absPath string) bool
    ValidateTmpfsMountDestination(dest string) error
    ValidateMountConfig(mt *mount.Mount) error

Parser represents a platform specific parser for mount expressions

func NewParser Uses

func NewParser(containerOS string) Parser

NewParser creates a parser for a given container OS, depending on the current host OS (linux on a windows host will resolve to an lcowParser)

Package mounts imports 15 packages (graph) and is imported by 5 packages. Updated 2020-05-18. Refresh now. Tools for package owners.