volume

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package volume is named volumes: trees that outlive the containers that mount them (run -v NAME:/path[:ro]), kept in the state store like containers are. A volume is a writable rootfs.FS with a quota; it is mounted into a container as a WASI preopen (runtime.Mount), so two containers mounting one volume share one tree.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("no such volume")
	ErrInUse    = errors.New("volume is in use")
	ErrInvalid  = errors.New("invalid volume")
	ErrTooMany  = errors.New("too many volumes")
)

Errors the API maps to statuses.

Functions

func DecodeRecord

func DecodeRecord(b []byte) (*record, error)

DecodeRecord reads a stored volume record (exported for the fuzzer).

func ValidName

func ValidName(name string) bool

ValidName reports whether name may name a volume.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager owns every volume.

func New

func New(opt Options) *Manager

New returns a manager; Restore loads stored volumes.

func (*Manager) Close

func (m *Manager) Close(ctx context.Context) error

Close stores what changed and stops the saver.

func (*Manager) Create

func (m *Manager) Create(name string, labels map[string]string) (*Volume, bool, error)

Create makes a volume, or returns the existing one of that name (Docker's create is idempotent). An empty name makes an anonymous one.

func (*Manager) Flush

func (m *Manager) Flush(ctx context.Context) error

Flush stores every volume that changed since its last store.

func (*Manager) Get

func (m *Manager) Get(name string) (*Volume, error)

Get finds a volume.

func (*Manager) List

func (m *Manager) List() []*Volume

List returns volumes by name.

func (*Manager) PersistError

func (m *Manager) PersistError() error

PersistError is the last failure to store a volume.

func (*Manager) Prune

func (m *Manager) Prune(all bool, inUse func(string) []string) ([]string, int64)

Prune removes unused volumes: anonymous ones, or with all every one.

func (*Manager) Remove

func (m *Manager) Remove(name string, inUse func(string) []string) error

Remove deletes a volume that no container uses.

func (*Manager) Restore

func (m *Manager) Restore(lim rootfs.Limits) ([]string, error)

Restore loads stored volumes; a record or content that fails its checks is dropped (the volume, or its content) and reported.

type Options

type Options struct {
	// Store keeps volumes across restarts (nil: memory only).
	Store state.Store
	// Quota bounds one volume (default 64 MiB, 16384 entries).
	Quota rootfs.Quota
	// Max bounds how many volumes exist (default 64).
	Max int
	// SaveEvery is how often changed volumes are stored (default 2s).
	SaveEvery time.Duration
}

Options configure a Manager.

type Volume

type Volume struct {
	Name      string
	CreatedAt time.Time
	Labels    map[string]string
	// Anonymous volumes were created without a name (prune removes them
	// by default).
	Anonymous bool
	// contains filtered or unexported fields
}

Volume is one named tree.

func (*Volume) FS

func (v *Volume) FS() *rootfs.FS

FS is the volume's tree.

func (*Volume) Size

func (v *Volume) Size() int64

Size is the bytes it holds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL