dockermem

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dockermem measures the memory a stack has to fit into, and what is already in it. mem_limit is a ceiling and not a reservation, so a stack declaring 13 GB across its services can run in 2 GB. See Usage.Shared.

Index

Constants

View Source
const WarnRatio = 0.85

WarnRatio is the share of the available memory above which starting one more stack is worth a warning.

Variables

This section is empty.

Functions

func Human

func Human(n int64) string

func ParseSize

func ParseSize(s string) (int64, error)

ParseSize reads the sizes docker stats prints, e.g. "334.2MiB", "1.47GiB".

Types

type Usage

type Usage struct {
	Total int64 // bytes the containers have to fit into
	Used  int64 // bytes already used, by the containers alone unless Shared
	// StackUsed excludes one-off `compose run` containers: a migration
	// container peaking at 6 GB is not what a stack costs, and counting it
	// would triple the estimate.
	StackUsed int64
	Projects  int // distinct compose projects, one-offs excluded
	// Shared says the daemon runs on the very machine wtm does, a native Linux
	// docker: Used is then what the whole machine uses, since a desktop holding
	// 6 GB is pressure the containers compete with but cannot see.
	Shared bool
}

func Read

func Read(ctx context.Context, runner execx.Runner) (Usage, error)

func (Usage) PerProject

func (u Usage) PerProject() int64

PerProject is the average cost of a running stack, the best available estimate of what one more would cost.

func (Usage) Projected

func (u Usage) Projected() int64

func (Usage) Tight

func (u Usage) Tight() bool

func (Usage) Warning

func (u Usage) Warning() string

Jump to

Keyboard shortcuts

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