Documentation ¶
Index ¶
- Constants
- Variables
- func IsArchive(header []byte) bool
- func PeriodicCleanupDeadContainers()
- type BuildOption
- func BuildArchiveReader(reader io.Reader) BuildOption
- func BuildArguments(args map[string]string) BuildOption
- func BuildCache(cache bool) BuildOption
- func BuildContext(ctx context.Context) BuildOption
- func BuildDockerFilePath(path string) BuildOption
- func BuildId(id string) BuildOption
- func BuildLabels(labels map[string]string) BuildOption
- func BuildQuiet(quiet bool) BuildOption
- func BuildTags(tags []string) BuildOption
- type BuildOptions
- type Client
- func (c *Client) Close() error
- func (c *Client) HasImage(refName string) bool
- func (c *Client) ImageBuild(iopts ...BuildOption) error
- func (c *Client) ImageBuildCached(iopts ...BuildOption) error
- func (c *Client) ImagePush(name0 string, pushOpts model.Push) error
- func (c *Client) ListImages(refName string) ([]types.ImageSummary, error)
- func (c *Client) PullImage(refName string) error
- func (c *Client) RemoveImage(refName string) error
- type ClientOption
- func APIVersion(s string) ClientOption
- func ClientContext(ctx context.Context) ClientOption
- func Host(s string) ClientOption
- func Stderr(stderr io.Writer) ClientOption
- func Stdin(stdin io.Reader) ClientOption
- func Stdout(stdout io.Writer) ClientOption
- func TLSConfig(certPath string, verify bool) ClientOption
- type ClientOptions
- type Container
- func (c *Container) Attach() error
- func (c *Container) Close() error
- func (c *Container) CopyFromContainer(sourcePath string) (io.ReadCloser, error)
- func (c *Container) CopyToContainer(targetPath string, content io.Reader) error
- func (c *Container) ForwardAllSignals() chan os.Signal
- func (c *Container) Info() (types.ContainerJSON, error)
- func (c *Container) MonitorTtySize() error
- func (c *Container) Options() ContainerOptions
- func (c *Container) Start() error
- func (c *Container) Stop() error
- type ContainerOption
- func AddEnv(k, v string) ContainerOption
- func AddVolume(dir string) ContainerOption
- func CUDADevice(n int) ContainerOption
- func Cmd(s []string) ContainerOption
- func ContainerConfig(h container.Config) ContainerOption
- func Device(d container.DeviceMapping) ContainerOption
- func Devices(ds []container.DeviceMapping) ContainerOption
- func Entrypoint(s []string) ContainerOption
- func GPUCount(cnt int) ContainerOption
- func HostConfig(h container.HostConfig) ContainerOption
- func Hostname(h string) ContainerOption
- func Image(s string) ContainerOption
- func Memory(n int64) ContainerOption
- func NetworkConfig(h network.NetworkingConfig) ContainerOption
- func NetworkDisabled(b bool) ContainerOption
- func NvidiaVolume(version string) ContainerOption
- func OpenStdin(b bool) ContainerOption
- func ReadonlyRootfs(b bool) ContainerOption
- func Runtime(s string) ContainerOption
- func Shell(s []string) ContainerOption
- func Timelimit(t time.Duration) ContainerOption
- func Tty(b bool) ContainerOption
- func User(u string) ContainerOption
- func WorkingDirectory(dir string) ContainerOption
- type ContainerOptions
- type Execution
- func (e *Execution) CombinedOutput() ([]byte, error)
- func (e *Execution) MonitorTtySize() error
- func (e *Execution) Output() ([]byte, error)
- func (e *Execution) Run() error
- func (e *Execution) Start() error
- func (e *Execution) StderrPipe() (io.ReadCloser, error)
- func (e *Execution) StdinPipe() (io.WriteCloser, error)
- func (e *Execution) StdoutPipe() (io.ReadCloser, error)
- func (e *Execution) Wait() error
- type ExitError
- type GPUUsageState
- type InStream
- type OutStream
- type Streams
Constants ¶
const ( // DefaultDockerfileName is the Default filename with Docker commands, read by docker build DefaultDockerfileName string = "Dockerfile" // HeaderSize is the size in bytes of a tar header HeaderSize = 512 )
Variables ¶
var ( Config = &dockerConfig{ done: make(chan struct{}), } )
var ( DefaultContainerEnv = map[string]string{ "CI": "rai", "RAI": "true", "RAI_ARCH": filepath.Join(runtime.GOOS, runtime.GOARCH), "RAI_USER": "root", "RAI_SOURCE_DIR": "/src", "RAI_DATA_DIR": "/data", "RAI_BUILD_DIR": "/build", "DATA_DIR": "/dir", "SOURCE_DIR": "/src", "BUILD_DIR": "/build", "TERM": "xterm", "PATH": "/usr/local/cuda/bin:/usr/local/nvidia/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "LD_LIBRARY_PATH": "/usr/local/cuda/lib64:/usr/local/nvidia/lib64", "SHELL": "/bin/bash", "SHELLOPTS": "braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor", } )
Functions ¶
func IsArchive ¶
IsArchive checks for the magic bytes of a tar or any supported compression algorithm.
func PeriodicCleanupDeadContainers ¶
func PeriodicCleanupDeadContainers()
cleanup dead containers and volumes frequently
Types ¶
type BuildOption ¶
type BuildOption func(*BuildOptions)
func BuildArchiveReader ¶
func BuildArchiveReader(reader io.Reader) BuildOption
func BuildArguments ¶
func BuildArguments(args map[string]string) BuildOption
func BuildCache ¶
func BuildCache(cache bool) BuildOption
func BuildContext ¶
func BuildContext(ctx context.Context) BuildOption
func BuildDockerFilePath ¶
func BuildDockerFilePath(path string) BuildOption
func BuildId ¶
func BuildId(id string) BuildOption
func BuildLabels ¶
func BuildLabels(labels map[string]string) BuildOption
func BuildQuiet ¶
func BuildQuiet(quiet bool) BuildOption
func BuildTags ¶
func BuildTags(tags []string) BuildOption
type BuildOptions ¶
type BuildOptions struct {
// contains filtered or unexported fields
}
func NewBuildOptions ¶
func NewBuildOptions(opts ...BuildOption) *BuildOptions
type Client ¶
func NewClient ¶
func NewClient(paramOpts ...ClientOption) (*Client, error)
func (*Client) ImageBuild ¶
func (c *Client) ImageBuild(iopts ...BuildOption) error
func (*Client) ImageBuildCached ¶
func (c *Client) ImageBuildCached(iopts ...BuildOption) error
func (*Client) ListImages ¶
func (c *Client) ListImages(refName string) ([]types.ImageSummary, error)
func (*Client) RemoveImage ¶
type ClientOption ¶
type ClientOption func(*ClientOptions)
func APIVersion ¶
func APIVersion(s string) ClientOption
func ClientContext ¶
func ClientContext(ctx context.Context) ClientOption
func Host ¶
func Host(s string) ClientOption
func Stderr ¶
func Stderr(stderr io.Writer) ClientOption
func Stdin ¶
func Stdin(stdin io.Reader) ClientOption
func Stdout ¶
func Stdout(stdout io.Writer) ClientOption
func TLSConfig ¶
func TLSConfig(certPath string, verify bool) ClientOption
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
func NewClientOptions ¶
func NewClientOptions(opts ...ClientOption) *ClientOptions
type Container ¶
type Container struct { ID string // contains filtered or unexported fields }
func NewContainer ¶
func NewContainer(client *Client, paramOpts ...ContainerOption) (*Container, error)
func (*Container) CopyFromContainer ¶
func (c *Container) CopyFromContainer(sourcePath string) (io.ReadCloser, error)
func (*Container) CopyToContainer ¶
func (*Container) ForwardAllSignals ¶
func (*Container) MonitorTtySize ¶
func (*Container) Options ¶
func (c *Container) Options() ContainerOptions
type ContainerOption ¶
type ContainerOption func(*ContainerOptions)
func AddEnv ¶
func AddEnv(k, v string) ContainerOption
func AddVolume ¶
func AddVolume(dir string) ContainerOption
func CUDADevice ¶
func CUDADevice(n int) ContainerOption
func Cmd ¶
func Cmd(s []string) ContainerOption
func ContainerConfig ¶
func ContainerConfig(h container.Config) ContainerOption
func Device ¶
func Device(d container.DeviceMapping) ContainerOption
func Devices ¶
func Devices(ds []container.DeviceMapping) ContainerOption
func Entrypoint ¶
func Entrypoint(s []string) ContainerOption
func GPUCount ¶
func GPUCount(cnt int) ContainerOption
func HostConfig ¶
func HostConfig(h container.HostConfig) ContainerOption
func Hostname ¶
func Hostname(h string) ContainerOption
func Image ¶
func Image(s string) ContainerOption
func Memory ¶
func Memory(n int64) ContainerOption
func NetworkConfig ¶
func NetworkConfig(h network.NetworkingConfig) ContainerOption
func NetworkDisabled ¶
func NetworkDisabled(b bool) ContainerOption
func NvidiaVolume ¶
func NvidiaVolume(version string) ContainerOption
func OpenStdin ¶
func OpenStdin(b bool) ContainerOption
func ReadonlyRootfs ¶
func ReadonlyRootfs(b bool) ContainerOption
func Runtime ¶
func Runtime(s string) ContainerOption
func Shell ¶
func Shell(s []string) ContainerOption
func Timelimit ¶
func Timelimit(t time.Duration) ContainerOption
func Tty ¶
func Tty(b bool) ContainerOption
func User ¶
func User(u string) ContainerOption
func WorkingDirectory ¶
func WorkingDirectory(dir string) ContainerOption
type ContainerOptions ¶
type ContainerOptions struct {
// contains filtered or unexported fields
}
func NewContainerOptions ¶
func NewContainerOptions(c *Client, opts ...ContainerOption) *ContainerOptions
type Execution ¶
type Execution struct { // Path is the path or name of the command in the container. Path string // Arguments to the command in the container, excluding the command // name as the first argument. Args []string // Env is environment variables to the command. If Env is nil, Run will use // Env specified on Method or pre-built container image. Env []string // Dir specifies the working directory of the command. If Dir is the empty // string, Run uses Dir specified on Method or pre-built container image. Dir string // Stdin specifies the process's standard input. // If Stdin is nil, the process reads from the null device (os.DevNull). // // Run will not close the underlying handle if the Reader is an *os.File // differently than os/exec. Stdin io.ReadCloser // Stdout and Stderr specify the process's standard output and error. // If either is nil, they will be redirected to the null device (os.DevNull). // // Run will not close the underlying handles if they are *os.File differently // than os/exec. Stdout io.Writer Stderr io.Writer // contains filtered or unexported fields }
func NewExecutionFromString ¶
func (*Execution) CombinedOutput ¶
func (*Execution) MonitorTtySize ¶
func (*Execution) StderrPipe ¶
func (e *Execution) StderrPipe() (io.ReadCloser, error)
func (*Execution) StdoutPipe ¶
func (e *Execution) StdoutPipe() (io.ReadCloser, error)
type ExitError ¶
type ExitError struct { // ExitCode holds the non-zero exit code of the container ExitCode int // Stderr holds the standard error output from the command // if it *Cmd executed through Output() and Cmd.Stderr was not // set. Stderr []byte }
ExitError reports an unsuccessful exit by a command.
type GPUUsageState ¶
type GPUUsageState struct {
*lru.Cache
}
var GPUDeviceUsageState *GPUUsageState
func NewGPUUsageState ¶
func NewGPUUsageState() (*GPUUsageState, error)
type InStream ¶
type InStream struct {
// contains filtered or unexported fields
}
InStream is an input stream used by the DockerCli to read user input
func NewInStream ¶
func NewInStream(in io.ReadCloser) *InStream
NewInStream returns a new InStream object from a ReadCloser
func (*InStream) CheckTty ¶
CheckTty checks if we are trying to attach to a container tty from a non-tty client input stream, and if so, returns an error.
func (*InStream) IsTerminal ¶
IsTerminal returns true if this stream is connected to a terminal
func (*InStream) RestoreTerminal ¶
func (i *InStream) RestoreTerminal()
RestoreTerminal restores normal mode to the terminal
func (*InStream) SetRawTerminal ¶
SetRawTerminal sets raw mode on the input terminal
type OutStream ¶
type OutStream struct {
// contains filtered or unexported fields
}
OutStream is an output stream used by the DockerCli to write normal program output.
func NewOutStream ¶
NewOutStream returns a new OutStream object from a Writer
func (*OutStream) GetTtySize ¶
GetTtySize returns the height and width in characters of the tty
func (*OutStream) IsTerminal ¶
IsTerminal returns true if this stream is connected to a terminal
func (*OutStream) RestoreTerminal ¶
func (o *OutStream) RestoreTerminal()
RestoreTerminal restores normal mode to the terminal
func (*OutStream) SetRawTerminal ¶
SetRawTerminal sets raw mode on the output terminal