docker

package
v0.0.0-...-aff87ba Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDockerRoot string = "/var/lib/docker"
View Source
const DefaultDockerVersion string = "1.10.0"

Variables

This section is empty.

Functions

func AddContainerLog

func AddContainerLog(logPath string, content string) error

AddContainerLog appends a single line of log to container's logfile For this version of daoker, only json-file is supported TODO: support more log drivers.

func ContainerVolumeUsage

func ContainerVolumeUsage(mp MountPoint) (string, int64, error)

ContainerVolumeUsage gets the disk usage and inode usage of a volume only internal volumes are considered like "VOLUME /var/lib/mysql" in Dockerfile we will skip "-v a:b" volumes

func GetContainerLogSize

func GetContainerLogSize(logFile string) string

GetContainerLogSize returns human readable size of container's log file

func GetDockerRoot

func GetDockerRoot() string

GetDockerRoot gets docker root path in Docker environment

func GetDockerVersion

func GetDockerVersion() string

GetDockerVersion gets docker version from env

func GetVolumeRoot

func GetVolumeRoot() string

GetVolumeRoot gets docker volume path in Docker environment

func IsValidStateString

func IsValidStateString(s string) bool

IsValidStateString checks if the provided string is a valid container state or not.

Types

type Container

type Container struct {
	ID          string
	State       State
	Pnum        int
	Created     time.Time
	Path        string
	Args        []string
	Config      *containertypes.Config
	MountPoints map[string]MountPoint
	Name        string
	LogPath     string
}

func Containers

func Containers() ([]Container, error)

Containers returns an array of docker containers unmarshaled from config.json in docker root path.

func GetContainer

func GetContainer(IDOrName string) (Container, error)

GetContainer returns a container by given IDOrName

type JSONLog

type JSONLog struct {
	Log     string    `json:"log,omitempty"`
	Stream  string    `json:"stream,omitempty"`
	Created time.Time `json:"time"`
}

type MountPoint

type MountPoint struct {
	Source      string // Container host directory
	Destination string // Inside the container
	RW          bool   // True if writable
	Name        string // Name set by user
	Driver      string // Volume driver to use

	// Note Mode is not used on Windows
	Mode string `json:"Relabel"` // Originally field was `Relabel`"

	// Note Propagation is not used on Windows
	Propagation string // Mount propagation string
	Named       bool   // specifies if the mountpoint was specified by name

	// 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:"-"`
}

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.

type State

type State struct {
	sync.Mutex
	// FIXME: Why do we have both paused and running if a
	// container cannot be paused and running at the same time?
	Running           bool
	Paused            bool
	Restarting        bool
	OOMKilled         bool
	RemovalInProgress bool // Not need for this to be persistent on disk.
	Dead              bool
	Pid               int
	ExitCode          int
	Error             string // contains last known error when starting the container
	StartedAt         time.Time
	FinishedAt        time.Time
	// contains filtered or unexported fields
}

State holds the current container state, and has methods to get and set the state. Container has an embed, which allows all of the functions defined against State to run against Container.

func NewState

func NewState() *State

NewState creates a default state object with a fresh channel for state changes.

func (*State) GetPID

func (s *State) GetPID() int

GetPID holds the process id of a container.

func (*State) IsPaused

func (s *State) IsPaused() bool

IsPaused returns whether the container is paused or not.

func (*State) IsRestarting

func (s *State) IsRestarting() bool

IsRestarting returns whether the container is restarting or not.

func (*State) IsRunning

func (s *State) IsRunning() bool

IsRunning returns whether the running flag is set. Used by Container to check whether a container is running.

func (*State) StateString

func (s *State) StateString() string

StateString returns a single string to describe state

func (*State) String

func (s *State) String() string

String returns a human-readable description of the state

Jump to

Keyboard shortcuts

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