container

package
v1.2.20 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	List(ctx context.Context, opts ...func(opt *ListOptions)) ([]entity.Container, error)
	//
	Create(ctx context.Context, opts ...func(opt *CreateOptions)) (dc.CreateResponse, error)
	Update(ctx context.Context, id string, opts ...func(opt *UpdateOptions)) (dc.ContainerUpdateOKBody, error)
	Remove(ctx context.Context, id string, opts ...func(opt *RemoveOptions)) error
	//
	Start(ctx context.Context, id string, opts ...func(opt *StartOptions)) error
	Stop(ctx context.Context, id string, opts ...func(opt *StopOptions)) error
	Restart(ctx context.Context, id string, opts ...func(opt *RestartOptions)) error
	//
	Inspect(ctx context.Context, id string, opts ...func(opt *InspectOptions)) (*types.ContainerJSON, error)
	//
	Stats(ctx context.Context, id string, opts ...func(opt *StatsOptions)) (io.ReadCloser, error)
	//
	Logs(ctx context.Context, id string, opts ...func(opt *LogsConfig)) (io.ReadCloser, error)
	//
	Exec(ctx context.Context, id string, opts ...func(opt *ExecOptions)) (*ExecTerm, error)
	//
	Run(ctx context.Context, opts ...func(opt *RunOptions)) error
}

Container is the docker container client interface

func New

func New(client *client.Client) Container

New creates a docker container client

type ContainerStats added in v1.2.17

type ContainerStats struct {
	Read      string `json:"read"`
	Preread   string `json:"preread"`
	PidsStats struct {
		Current int `json:"current"`
	} `json:"pids_stats"`
	BlkioStats struct {
		IoServiceBytesRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_service_bytes_recursive"`
		IoServicedRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_serviced_recursive"`
		IoQueueRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_queue_recursive"`
		IoServiceTimeRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_service_time_recursive"`
		IoWaitTimeRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_wait_time_recursive"`
		IoMergedRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_merged_recursive"`
		IoTimeRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_time_recursive"`
		SectorsRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"sectors_recursive"`
	} `json:"blkio_stats"`
	NumProcs     int `json:"num_procs"`
	StorageStats struct {
	} `json:"storage_stats"`
	PrecpuStats struct {
		CPUUsage struct {
			TotalUsage        int   `json:"total_usage"`
			PercpuUsage       []int `json:"percpu_usage"`
			UsageInKernelmode int   `json:"usage_in_kernelmode"`
			UsageInUsermode   int   `json:"usage_in_usermode"`
		} `json:"cpu_usage"`
		SystemCPUUsage int `json:"system_cpu_usage"`
		OnlineCPUs     int `json:"online_cpus"`
		ThrottlingData struct {
			Periods          int `json:"periods"`
			ThrottledPeriods int `json:"throttled_periods"`
			ThrottledTime    int `json:"throttled_time"`
		} `json:"throttling_data"`
	} `json:"precpu_stats"`
	CPUStats struct {
		CPUUsage struct {
			TotalUsage        int   `json:"total_usage"`
			UsageInKernelmode int   `json:"usage_in_kernelmode"`
			UsageInUsermode   int   `json:"usage_in_usermode"`
			PercpuUsage       []int `json:"percpu_usage"`
		} `json:"cpu_usage"`
		SystemCPUUsage int `json:"system_cpu_usage"`
		OnlineCPUs     int `json:"online_cpus"`
		ThrottlingData struct {
			Periods          int `json:"periods"`
			ThrottledPeriods int `json:"throttled_periods"`
			ThrottledTime    int `json:"throttled_time"`
		} `json:"throttling_data"`
	} `json:"cpu_stats"`
	MemoryStats struct {
		Usage    int `json:"usage"`
		MaxUsage int `json:"max_usage"`
		Stats    struct {
			ActiveAnon            int `json:"active_anon"`
			ActiveFile            int `json:"active_file"`
			Anon                  int `json:"anon"`
			AnonThp               int `json:"anon_thp"`
			File                  int `json:"file"`
			FileDity              int `json:"file_dirty"`
			FileMapped            int `json:"file_mapped"`
			FileWriteback         int `json:"file_writeback"`
			InactiveAnon          int `json:"inactive_anon"`
			InactiveFile          int `json:"inactive_file"`
			KernelStack           int `json:"kernel_stack"`
			Pgfault               int `json:"pgfault"`
			Pglazyfree            int `json:"pglazyfree"`
			Pglazyfreed           int `json:"pglazyfreed"`
			Pgmajfault            int `json:"pgmajfault"`
			Pgrefill              int `json:"pgrefill"`
			Pgscan                int `json:"pgscan"`
			Pgsteal               int `json:"pgsteal"`
			Shmem                 int `json:"shmem"`
			Slab                  int `json:"slab"`
			SlabReclaimable       int `json:"slab_reclaimable"`
			SlabUnreclaimable     int `json:"slab_unreclaimable"`
			Sock                  int `json:"sock"`
			ThpCollapseAlloc      int `json:"thp_collapse_alloc"`
			ThpFaultAlloc         int `json:"thp_fault_alloc"`
			Unevictable           int `json:"unevictable"`
			WorkingsetActivate    int `json:"workingset_activate"`
			WorkingsetNodereclaim int `json:"workingset_nodereclaim"`
			WorkingsetRefault     int `json:"workingset_refault"`
			//
			TotalInactiveFile int `json:"total_inactive_file"`
		} `json:"stats"`
		Limit int `json:"limit"`
	} `json:"memory_stats"`
	Networks map[string]struct {
		RxBytes   int `json:"rx_bytes"`
		RxPackets int `json:"rx_packets"`
		RxErrors  int `json:"rx_errors"`
		RxDropped int `json:"rx_dropped"`
		TxBytes   int `json:"tx_bytes"`
		TxPackets int `json:"tx_packets"`
		TxErrors  int `json:"tx_errors"`
		TxDropped int `json:"tx_dropped"`
	} `json:"networks"`
	Name string `json:"name"`
	ID   string `json:"id"`
}

func (*ContainerStats) BlockIO added in v1.2.17

func (c *ContainerStats) BlockIO() (read float64, write float64)

func (*ContainerStats) CPUPercentage added in v1.2.17

func (c *ContainerStats) CPUPercentage() float64

func (*ContainerStats) Memory added in v1.2.17

func (c *ContainerStats) Memory() float64

func (*ContainerStats) MemoryLimit added in v1.2.17

func (c *ContainerStats) MemoryLimit() float64

func (*ContainerStats) MemoryPercentage added in v1.2.17

func (c *ContainerStats) MemoryPercentage() float64

func (*ContainerStats) Network added in v1.2.17

func (c *ContainerStats) Network() (rx float64, tx float64)

func (*ContainerStats) PidsCurrent added in v1.2.17

func (c *ContainerStats) PidsCurrent() int

type CreateOptions added in v1.2.0

type CreateOptions struct {
	Name string
	//
	Container *co.Config
	Host      *co.HostConfig
	Network   *network.NetworkingConfig
	Platform  *specs.Platform
}

type ExecOptions added in v1.2.0

type ExecOptions struct {
	Detach bool
	Tty    bool
	Cmd    []string
	//
	AttachStdin bool
}

ExecOptions is the options for Exec.

type ExecStream added in v1.2.9

type ExecStream struct {
	types.HijackedResponse
}

func (*ExecStream) Close added in v1.2.9

func (s *ExecStream) Close() error

func (*ExecStream) Read added in v1.2.9

func (s *ExecStream) Read(p []byte) (n int, err error)

func (*ExecStream) Write added in v1.2.9

func (s *ExecStream) Write(p []byte) (n int, err error)

type ExecTerm added in v1.2.13

type ExecTerm struct {
	io.ReadWriteCloser
	Resize func(width, height uint) error
}

type InspectOptions added in v1.2.0

type InspectOptions struct {
}

type ListOptions added in v1.2.0

type ListOptions = tc.ListOptions

type LogsConfig added in v1.2.0

type LogsConfig struct {
	Follow     bool
	Timestamps bool
	Tail       string
	Since      string
	Until      string
	Details    bool
}

type RemoveOptions added in v1.2.0

type RemoveOptions = tc.RemoveOptions

type RestartOptions added in v1.2.0

type RestartOptions = StopOptions

type RunOptions added in v1.2.0

type RunOptions struct {
	Name string
	//
	Container *co.Config
	Host      *co.HostConfig
	Network   *network.NetworkingConfig
	Platform  *specs.Platform
	//
	Detached bool
	//
	Stdin  io.Reader
	Stdout io.WriteCloser
	Stderr io.WriteCloser
}

RunOptions is the configuration for running a container

type StartOptions added in v1.2.0

type StartOptions = tc.StartOptions

type StatsOptions added in v1.2.0

type StatsOptions struct {
	Stream bool
}

type StatsReadCloser added in v1.2.17

type StatsReadCloser struct {
	io.ReadCloser
}

func (*StatsReadCloser) Close added in v1.2.17

func (s *StatsReadCloser) Close() error

func (*StatsReadCloser) Read added in v1.2.17

func (s *StatsReadCloser) Read(p []byte) (int, error)

type StopOptions added in v1.2.0

type StopOptions struct {
	// Timeout (optional) is the timeout (in seconds) to wait for the container
	// to stop gracefully before forcibly terminating it with SIGKILL.
	//
	// - Use nil to use the default timeout (10 seconds).
	// - Use '-1' to wait indefinitely.
	// - Use '0' to not wait for the container to exit gracefully, and
	//   immediately proceeds to forcibly terminating the container.
	// - Other positive values are used as timeout (in seconds).
	Timeout int `json:",omitempty"`

	// Signal (optional) is the signal to send to the container to (gracefully)
	// stop it before forcibly terminating the container with SIGKILL after the
	// timeout expires. If not value is set, the default (SIGTERM) is used.
	Signal string `json:"signal,omitempty"`
}

StopOptions holds the options to stop or restart a container.

type UpdateOptions added in v1.2.0

type UpdateOptions struct {
	co.Resources
	RestartPolicy co.RestartPolicy
}

Jump to

Keyboard shortcuts

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