Documentation ¶
Overview ¶
Package docker allows to interact with Docker and docker-compose resources.
Index ¶
- func Build(t testing.TestingT, path string, options *BuildOptions)
- func BuildE(t testing.TestingT, path string, options *BuildOptions) error
- func GetDockerHost() string
- func Run(t testing.TestingT, image string, options *RunOptions) string
- func RunAndGetID(t testing.TestingT, image string, options *RunOptions) string
- func RunAndGetIDE(t testing.TestingT, image string, options *RunOptions) (string, error)
- func RunDockerCompose(t testing.TestingT, options *Options, args ...string) string
- func RunDockerComposeAndGetStdOut(t testing.TestingT, options *Options, args ...string) string
- func RunDockerComposeE(t testing.TestingT, options *Options, args ...string) (string, error)
- func RunE(t testing.TestingT, image string, options *RunOptions) (string, error)
- func Stop(t testing.TestingT, containers []string, options *StopOptions) string
- func StopE(t testing.TestingT, containers []string, options *StopOptions) (string, error)
- type BuildOptions
- type ContainerInspect
- type HealthCheck
- type HealthLog
- type Options
- type Port
- type RunOptions
- type StopOptions
- type VolumeBind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶ added in v0.22.3
func Build(t testing.TestingT, path string, options *BuildOptions)
Build runs the 'docker build' command at the given path with the given options and fails the test if there are any errors.
func BuildE ¶ added in v0.22.3
func BuildE(t testing.TestingT, path string, options *BuildOptions) error
BuildE runs the 'docker build' command at the given path with the given options and returns any errors.
func GetDockerHost ¶ added in v0.30.11
func GetDockerHost() string
GetDockerHost returns the name or address of the host on which the Docker engine is running.
func Run ¶ added in v0.22.3
func Run(t testing.TestingT, image string, options *RunOptions) string
Run runs the 'docker run' command on the given image with the given options and return stdout/stderr. This method fails the test if there are any errors.
func RunAndGetID ¶ added in v0.26.5
func RunAndGetID(t testing.TestingT, image string, options *RunOptions) string
RunAndGetID runs the 'docker run' command on the given image with the given options and returns the container ID that is returned in stdout. This method fails the test if there are any errors.
func RunAndGetIDE ¶ added in v0.26.5
RunAndGetIDE runs the 'docker run' command on the given image with the given options and returns the container ID that is returned in stdout, or any error.
func RunDockerCompose ¶
RunDockerCompose runs docker-compose with the given arguments and options and return stdout/stderr.
func RunDockerComposeAndGetStdOut ¶ added in v0.30.7
RunDockerComposeAndGetStdout runs docker-compose with the given arguments and options and returns only stdout.
func RunDockerComposeE ¶
RunDockerComposeE runs docker-compose with the given arguments and options and return stdout/stderr.
func RunE ¶ added in v0.22.3
RunE runs the 'docker run' command on the given image with the given options and return stdout/stderr, or any error.
Types ¶
type BuildOptions ¶ added in v0.22.3
type BuildOptions struct { // Tags for the Docker image Tags []string // Build args to pass the 'docker build' command BuildArgs []string // Target build arg to pass to the 'docker build' command Target string // Custom CLI options that will be passed as-is to the 'docker build' command. This is an "escape hatch" that allows // Terratest to not have to support every single command-line option offered by the 'docker build' command, and // solely focus on the most important ones. OtherOptions []string // Set a logger that should be used. See the logger package for more info. Logger *logger.Logger }
BuildOptions defines options that can be passed to the 'docker build' command.
type ContainerInspect ¶ added in v0.26.5
type ContainerInspect struct { // ID of the inspected container ID string // Name of the inspected container Name string // time.Time that the container was created Created time.Time // String representing the container's status Status string // Whether the container is currently running or not Running bool // Container's exit code ExitCode uint8 // String with the container's error message, if there is any Error string // Ports exposed by the container Ports []Port // Volume bindings made to the container Binds []VolumeBind // Health check Health HealthCheck }
ContainerInspect defines the output of the Inspect method, with the options returned by 'docker inspect' converted into a more friendly and testable interface
type HealthCheck ¶ added in v0.27.1
type HealthCheck struct { // Health check status Status string // Current count of failing health checks FailingStreak uint8 // Log of failures Log []HealthLog }
HealthCheck represents the current health history of the container
type HealthLog ¶ added in v0.27.1
type HealthLog struct { // Start time of health check Start string // End time of health check End string // Exit code of health check ExitCode uint8 // Output of health check Output string }
HealthLog represents the output of a single Health check of the container
type Options ¶
type Options struct { WorkingDir string EnvVars map[string]string // Set a logger that should be used. See the logger package for more info. Logger *logger.Logger }
Options are Docker options.
type RunOptions ¶ added in v0.22.3
type RunOptions struct { // Override the default COMMAND of the Docker image Command []string // If set to true, pass the --detach flag to 'docker run' to run the container in the background Detach bool // Override the default ENTRYPOINT of the Docker image Entrypoint string // Set environment variables EnvironmentVariables []string // If set to true, pass the --init flag to 'docker run' to run an init inside the container that forwards signals // and reaps processes Init bool // Assign a name to the container Name string // If set to true, pass the --privileged flag to 'docker run' to give extended privileges to the container Privileged bool // If set to true, pass the --rm flag to 'docker run' to automatically remove the container when it exits Remove bool // If set to true, pass the -tty flag to 'docker run' to allocate a pseudo-TTY Tty bool // Username or UID User string // Bind mount these volume(s) when running the container Volumes []string // Custom CLI options that will be passed as-is to the 'docker run' command. This is an "escape hatch" that allows // Terratest to not have to support every single command-line option offered by the 'docker run' command, and // solely focus on the most important ones. OtherOptions []string // Set a logger that should be used. See the logger package for more info. Logger *logger.Logger }
RunOptions defines options that can be passed to the 'docker run' command.
type StopOptions ¶ added in v0.23.2
type StopOptions struct { // Seconds to wait for stop before killing the container (default 10) Time int // Set a logger that should be used. See the logger package for more info. Logger *logger.Logger }
StopOptions defines the options that can be passed to the 'docker stop' command
type VolumeBind ¶ added in v0.26.5
VolumeBind represents a single volume binding made to the container