containeroptions

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SetOptionsFns

type SetOptionsFns func(options *container.Config)

func AttachStderr

func AttachStderr() SetOptionsFns

Sets attach stderr to true in the container configuration

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	AttachStderr(),
)

func AttachStdin

func AttachStdin() SetOptionsFns

Sets attatch stdin to true in the container configuration

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.AttachStdin(),
)

func AttachStdout

func AttachStdout() SetOptionsFns

Sets attach stdout to true in the container configuration

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.AttachStdout(),
)

func CMD

func CMD(cmd ...string) SetOptionsFns

Adds a command to the container configuration.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.CMD("/bin/sh", "-c", "echo hello"),
)

func DisableHealthCheck

func DisableHealthCheck() SetOptionsFns

Disables the health check

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.DisableHealthCheck()
)

func DisableNetwork

func DisableNetwork() SetOptionsFns

Sets The network to diabled in the container configuration.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.DisableNetwork(),
)

func DomainName

func DomainName(name string) SetOptionsFns

Adds a domain name to the container configuration.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.DomainName("com.example.localhost"),
)

func Entrypoint

func Entrypoint(entrypoint ...string) SetOptionsFns

Sets the entrypoint command for the container.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.Entrypoint("/docker-entrypoint.sh"),
)

func Env

func Env(key string, value string) SetOptionsFns

func EscapeArgs

func EscapeArgs() SetOptionsFns

Sets ArsExcaped to true in the container configuration. Use if command is already escaped (meaning treat as a command line) (Windows specific).

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.EscapeArgs(),
)

func Expose

func Expose(containerPort string) SetOptionsFns

Exposes a port

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.Expose("8000")
)

func HealthCheckExec

func HealthCheckExec(start, timeout, interval time.Duration, retries int, args ...string) SetOptionsFns

Adds a health check to the container configuration that exec arguments directly

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.HealthCheckExec(
		time.Second*5,  //start
		time.Second*20, //timeout
		time.Second*5, //interval
		10, //timeout
		"CMD-SHELL", "curl", "-f", "http://localhost", "||", "exit", "1",
	)
)

func Hostname

func Hostname(name string) SetOptionsFns

Adds a hostname to the container configuration.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.Hostname("com.example.localhost"),
)

func Image

func Image(image fmt.Stringer) SetOptionsFns

Adds a image to the container configuration.

image := client.NewImage("alpine")
myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.Image(image),
)

func Label

func Label(label, value string) SetOptionsFns

Adds a label to the container configuration.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.Label("my_label", "my_value"),
)

func OnBuild

func OnBuild(args ...string) SetOptionsFns

Sets the ONBUILD metadata that were defined on the image Dockerfile

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.OnBuild("ADD", "."),
)

func OpenStdin

func OpenStdin() SetOptionsFns

Sets OpenStdin to true in the container configuration

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.OpenStdin(),
)

func SetStderrAttach

func SetStderrAttach(attach bool) SetOptionsFns

Sets whether to attach to stderr. This is similar to AttachStderr() but allows explicitly setting it to false.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.SetStderrAttach(false),
)

func SetStdinAttach

func SetStdinAttach(attach bool) SetOptionsFns

Sets whether to attach to stdin. This is similar to AttachStdin() but allows explicitly setting it to false.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.SetStdinAttach(false),
)

func SetStdinOpen

func SetStdinOpen(open bool) SetOptionsFns

Sets whether stdin should be kept open even if not attached. This is similar to OpenStdin() but allows explicitly setting it to false.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.SetStdinOpen(false),
)

func SetStdoutAttach

func SetStdoutAttach(attach bool) SetOptionsFns

Sets whether to attach to stdout. This is similar to AttachStdout() but allows explicitly setting it to false.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.SetStdoutAttach(false),
)

func SetTTY

func SetTTY(enabled bool) SetOptionsFns

Sets whether the container should run with a terminal attached. This is similar to TTY() but allows explicitly setting it to false.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.SetTTY(false),
)

func Shell

func Shell(shell ...string) SetOptionsFns

Sets a custom shell to use when the image does not have /bin/sh. This is used when running shell form commands.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.Shell("/bin/bash"),
)

func StdinOnce

func StdinOnce() SetOptionsFns

Sets StdinOnce to true in the container configuration that closes stdin after the 1 attached client disconnects.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.StdinOnce(),
)

func StopSignal

func StopSignal(signal string) SetOptionsFns

Adds a StopSignal to the container configuration.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.StopSignal("SIGTERM"),
)

func StopTimeout

func StopTimeout(timeout int) SetOptionsFns

Sets the timeout in seconds to stop the container.

Usage example:

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.StopTimeout(30),
)

func TTY

func TTY() SetOptionsFns

Sets TTY to true in the container configuration

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.TTY(),
)

func User

func User(user string) SetOptionsFns

Sets a user for the container configuration

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.User("my_user"),
)

func Volume

func Volume(volume fmt.Stringer) SetOptionsFns

Adds a volume to the container configuration.

myVolume := volume.NewConfig("my_volume")
myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.Volume(volume),
)

func WorkingDir

func WorkingDir(dir string) SetOptionsFns

Sets the working directory for the container configuration.

myContainer := container.NewConfig("my_container")
myContainer.SetContainerOptions(
	containeroptions.WorkingDir("/my/working/directory"),
)

Jump to

Keyboard shortcuts

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