Documentation
¶
Index ¶
- Variables
- type CommandExecutor
- type Docker
- func (d *Docker) Build(dockerfileContent, imageName, platform, buildContext string) error
- func (d *Docker) Login(username string, password string) error
- func (d *Docker) Logout() error
- func (d *Docker) Push(imageName string) (string, error)
- func (d *Docker) Run(imageName, platform, containerName string, rm, detach bool, gpus string, ...) (string, error)
- type Executor
Constants ¶
This section is empty.
Variables ¶
var ErrMissingGPUDriver = errors.New("docker could not find the required gpu driver")
ErrMissingGPUDriver is the expected error if docker is unable to find the required gpu driver.
Functions ¶
This section is empty.
Types ¶
type CommandExecutor ¶
type CommandExecutor struct{}
CommandExecutor is a struct that provides an implementation for executing system commands.
type Docker ¶
type Docker struct {
RegistryHost string
// contains filtered or unexported fields
}
Docker is a struct used to interact with the Docker CLI.
func NewDocker ¶
NewDocker creates a new instance of the Docker struct.
registryHost is the host of the Docker registry to interact with. executor is an instance of the Executor interface, which handles command execution.
Returns a pointer to a Docker struct.
func (*Docker) Build ¶
Build builds a Docker image using buildx and loads the image into the local Docker daemon.
dockerfileContent is the content of the Dockerfile. imageName is the name and tag to apply to the resulting image. This function automatically prefixes it with the value of RegistryHost followed by a forward slash. platform is the target platform for the build (e.g., "linux/amd64"). buildContext is the context of the build.
Returns an error if the build fails.
func (*Docker) Push ¶
Push pushes a Docker image to the registry.
imageName is the name and tag of the image to push. This function automatically prefixes it with the value of RegistryHost followed by a forward slash.
Returns the image digest on success or an error on failure.
func (*Docker) Run ¶
func (d *Docker) Run(imageName, platform, containerName string, rm, detach bool, gpus string, envVars, ports, volumes, command []string) (string, error)
Run runs a Docker container using the provided image name, platform, and additional options.
imageName is the name and tag of the image to run. This function automatically prefixes it with the value of RegistryHost followed by a forward slash. platform is the target platform for the container (e.g., "linux/amd64"). containerName is the name to assign to the running container. rm specifies if the container should be removed after it stops. detach specifies if the container should run in detached mode. gpus specifies the gpus to use. An empty string means that no gpus need to be used. envVars is a list of environment variables to set in the container (e.g., "KEY=value"). ports is a list of port mappings (e.g., "8080:80"). volumes is a list of volume mappings between the host and the container (e.g., "/host/path:/container/path"). command is the command to execute inside the container. If left empty, Docker will use the default command defined by the image.
If the required Nvidia GPU driver is not found, it returns ErrMissingGPUDriver. If there is any other error, it returns that error. Otherwise it returns the output.