docker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package docker provides methods for creating and managing docker containers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerConfig

type ContainerConfig struct {
	ForBuild   bool          // Determines if the config is meant to be used
	Image      string        // Image which will be used for running code
	LocalImage bool          // Set to true if image shouldn't be pulled from the outside
	Cmd        []string      // Defines what will be run when container starts. Use "..." as a name of the file
	TimeLimit  time.Duration // Max time for the container to run
	MemoryMB   int64         // Container memory limit (in megabytes)
}

ContainerConfig describes what configuration the container should have

type ContainerFile

type ContainerFile struct {
	FileName string // Name of file that will contain all the Content
	Content  string // Code that will be executed
}

ContainerFile describes what file the container should execute

type Controller

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

Controller is an object that wll be used for running methods off of it

func NewController

func NewController(config *ContainerConfig) (c *Controller, err error)

NewController returns Controller that wll be used for running methods off of it

func (*Controller) ContainerCreate

func (c *Controller) ContainerCreate(userConfig *ContainerConfig, volumes []VolumeMount) (containerID string, err error)

ContainerCreate creates a container

func (*Controller) ContainerLog

func (c *Controller) ContainerLog(containerID string) (string, error)

ContainerLog returns logs of a specific container

func (*Controller) ContainerRemove

func (c *Controller) ContainerRemove(containerID string) error

ContainerRemove removes a container

func (*Controller) ContainerStart

func (c *Controller) ContainerStart(containerID string) error

ContainerStart starts a container

func (*Controller) ContainerWait

func (c *Controller) ContainerWait(containerID string, timeLimit time.Duration) (state int64, err error)

ContainerWait waits until the container is stopped

func (*Controller) EnsureImage

func (c *Controller) EnsureImage(imageName string) error

EnsureImage pulls images from docker hub to make sure in exists

func (*Controller) EnsureVolume

func (c *Controller) EnsureVolume(name string) (new bool, volume *types.Volume, err error)

EnsureVolume makes sure specified volume exists and creates it if it doesn't

func (*Controller) FindVolume

func (c *Controller) FindVolume(name string) (volume *types.Volume, err error)

FindVolume finds a specified volume

func (*Controller) RemoveVolume

func (c *Controller) RemoveVolume(name string) error

RemoveVolume removes specified volume

func (*Controller) Run

func (c *Controller) Run() (statusCode int64, logs string, err error)

Run creates, runs and removes container defined by the ContainerConfig

type VolumeMount

type VolumeMount struct {
	HostPath string
	Volume   *types.Volume
}

VolumeMount is used for specifying volumes for the container to mount

Jump to

Keyboard shortcuts

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