Documentation
¶
Overview ¶
Package cc provides the options for the container config.
Index ¶
- func Fail(err error) create.SetContainerConfig
- func Failf(stringFormat string, args ...interface{}) create.SetContainerConfig
- func WithAttachedStderr() create.SetContainerConfig
- func WithAttachedStdin() create.SetContainerConfig
- func WithAttachedStdout() create.SetContainerConfig
- func WithCommand(cmd ...string) create.SetContainerConfig
- func WithCommandHealthCheck(interval int, cmds ...string) create.SetContainerConfig
- func WithCurlHealthCheck(url string, interval int) create.SetContainerConfig
- func WithDisabledHealthCheck() create.SetContainerConfig
- func WithDisabledNetwork() create.SetContainerConfig
- func WithDockerSocketHealthCheck(interval int) create.SetContainerConfig
- func WithDomainName(domainname string) create.SetContainerConfig
- func WithEntrypoint(entrypoint ...string) create.SetContainerConfig
- func WithEnv(key string, value string) create.SetContainerConfig
- func WithEscapedArgs() create.SetContainerConfig
- func WithExposedPort(protocol string, port string) create.SetContainerConfig
- func WithFileExistsHealthCheck(filePath string, interval int) create.SetContainerConfig
- func WithHealthCheck(setters ...health.SetHealthcheckConfig) create.SetContainerConfig
- func WithHostName(hostname string) create.SetContainerConfig
- func WithImage(image string) create.SetContainerConfig
- func WithImagef(stringFormat string, args ...interface{}) create.SetContainerConfig
- func WithLabel(label, value string) create.SetContainerConfig
- func WithLogFileContainsHealthCheck(logFile, pattern string, interval int) create.SetContainerConfig
- func WithMacAddress(macAddress string) create.SetContainerConfigdeprecated
- func WithOnBuild(args ...string) create.SetContainerConfig
- func WithShell(shell ...string) create.SetContainerConfig
- func WithStdinOnce() create.SetContainerConfig
- func WithStdinOpen() create.SetContainerConfig
- func WithStopSignal(signal string) create.SetContainerConfig
- func WithStopTimeout(timeout int) create.SetContainerConfig
- func WithTCPHealthCheck(host string, port string, interval int) create.SetContainerConfig
- func WithTty() create.SetContainerConfig
- func WithUser(user string) create.SetContainerConfig
- func WithVolume(volume string) create.SetContainerConfig
- func WithWorkingDir(dir string) create.SetContainerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fail ¶
func Fail(err error) create.SetContainerConfig
Fail is a function that returns an error
note: this is useful for when you want to fail the container config and append the error to the container config error collection
func Failf ¶
func Failf(stringFormat string, args ...interface{}) create.SetContainerConfig
Failf is a function that returns an error
note: this is useful for when you want to fail the container config and append the error to the container config error collection
func WithAttachedStderr ¶
func WithAttachedStderr() create.SetContainerConfig
WithAttachedStderr enables attaching to container's standard error
func WithAttachedStdin ¶
func WithAttachedStdin() create.SetContainerConfig
WithAttachedStdin enables attaching to container's standard input
func WithAttachedStdout ¶
func WithAttachedStdout() create.SetContainerConfig
WithAttachedStdout enables attaching to container's standard output
func WithCommand ¶
func WithCommand(cmd ...string) create.SetContainerConfig
WithCommand sets the command to be run in the container Parameters:
- cmd: command and its arguments
func WithCommandHealthCheck ¶
func WithCommandHealthCheck(interval int, cmds ...string) create.SetContainerConfig
WithCommandHealthCheck executes an arbitrary shell command. it has a default start period of 5 seconds, a timeout of 5 seconds, a retries of 3, and an interval of the parameter interval parameters:
- cmds: the commands ran in the health check
- interval: the interval in seconds between health checks
"CMD-SHELL", cmds...
func WithCurlHealthCheck ¶
func WithCurlHealthCheck(url string, interval int) create.SetContainerConfig
WithCurlHealthCheck sets a health check that uses curl to check if the container is healthy it has a default start period of 5 seconds, a timeout of 10 seconds, a retries of 5, and an interval of the specified interval in seconds parameters:
- url: the URL to check
- interval: the interval in seconds between health checks
"CMD-SHELL", "curl -f "+url+" || exit 1"
func WithDisabledHealthCheck ¶
func WithDisabledHealthCheck() create.SetContainerConfig
WithDisabledHealthCheck disables the health check by setting it to NONE.
func WithDisabledNetwork ¶
func WithDisabledNetwork() create.SetContainerConfig
WithDisabledNetwork disables networking for the container
func WithDockerSocketHealthCheck ¶
func WithDockerSocketHealthCheck(interval int) create.SetContainerConfig
WithDockerSocketHealthCheck ensures /var/run/docker.sock exists. it has a default start period of 5 seconds, a timeout of 5 seconds, a retries of 3, and an interval of the parameter interval parameters:
- interval: the interval in seconds between health checks
"CMD-SHELL", "[ -S /var/run/docker.sock ] || exit 1"
func WithDomainName ¶
func WithDomainName(domainname string) create.SetContainerConfig
WithDomainName sets the domain name of the container
func WithEntrypoint ¶
func WithEntrypoint(entrypoint ...string) create.SetContainerConfig
WithEntrypoint sets the entrypoint to be run within the container
func WithEnv ¶
func WithEnv(key string, value string) create.SetContainerConfig
WithEnv appends an environment variable and its value to the container configuration Parameters:
- key: environment variable name
- value: environment variable value
func WithEscapedArgs ¶
func WithEscapedArgs() create.SetContainerConfig
WithEscapedArgs indicates that command arguments are already escaped
func WithExposedPort ¶
func WithExposedPort(protocol string, port string) create.SetContainerConfig
WithExposedPort appends a port to be exposed from the container Parameter:
- port: port number or port range to be exposed in the container (e.g., "80-1000" or "80")
- protocol: protocol to be exposed from the container
func WithFileExistsHealthCheck ¶
func WithFileExistsHealthCheck(filePath string, interval int) create.SetContainerConfig
WithFileExistsHealthCheck checks if a specific file exists. it has a default start period of 5 seconds, a timeout of 5 seconds, a retries of 3, and an interval of the parameter interval parameters:
- filePath: the file path to check
- interval: the interval in seconds between health checks
"CMD-SHELL", "[ -f "+filePath+" ] || exit 1"
func WithHealthCheck ¶
func WithHealthCheck(setters ...health.SetHealthcheckConfig) create.SetContainerConfig
WithHealthCheck sets the health check for the container parameters:
- healthCheckFns: the health check functions to set
func WithHostName ¶
func WithHostName(hostname string) create.SetContainerConfig
WithHostName sets the hostname of the container
func WithImage ¶
func WithImage(image string) create.SetContainerConfig
WithImage sets the image to use for the container
func WithImagef ¶
func WithImagef(stringFormat string, args ...interface{}) create.SetContainerConfig
func WithLabel ¶
func WithLabel(label, value string) create.SetContainerConfig
WithLabel appends a label to the container Parameters:
- label: label key
- value: label value
func WithLogFileContainsHealthCheck ¶
func WithLogFileContainsHealthCheck(logFile, pattern string, interval int) create.SetContainerConfig
WithLogFileContainsHealthCheck waits for a pattern in a log file. it has a default start period of 5 seconds, a timeout of 5 seconds, a retries of 3, and an interval of the parameter interval parameters:
- logFile: the log file to check
- pattern: the pattern to check for
- interval: the interval in seconds between health checks
"CMD-SHELL", "grep -q "+pattern+" "+logFile+" || exit 1"
func WithMacAddress
deprecated
func WithMacAddress(macAddress string) create.SetContainerConfig
WithMacAddress sets the MAC address for the container Parameter:
- macAddress: MAC address to be used for the container
Deprecated: this function is deprecated since docker API v1.44. Use nc.WithMacAddress(string) instead.
func WithOnBuild ¶
func WithOnBuild(args ...string) create.SetContainerConfig
WithOnBuild appends ONBUILD metadata that will trigger when the image is used as a base image
func WithShell ¶
func WithShell(shell ...string) create.SetContainerConfig
WithShell sets the shell for shell-form of RUN, CMD, ENTRYPOINT
func WithStdinOnce ¶
func WithStdinOnce() create.SetContainerConfig
WithStdinOnce closes STDIN after the first attach
func WithStdinOpen ¶
func WithStdinOpen() create.SetContainerConfig
WithStdinOpen keeps STDIN open even if not attached
func WithStopSignal ¶
func WithStopSignal(signal string) create.SetContainerConfig
WithStopSignal sets the signal that will be used to stop the container
func WithStopTimeout ¶
func WithStopTimeout(timeout int) create.SetContainerConfig
WithStopTimeout sets the timeout (in seconds) to stop the container
note: is also stop_grace_period in compose
func WithTCPHealthCheck ¶
func WithTCPHealthCheck(host string, port string, interval int) create.SetContainerConfig
WithTCPHealthCheck checks if a TCP port is open using netcat. it has a default start period of 5 seconds, a timeout of 5 seconds, a retries of 3, and an interval of the parameter interval parameters:
- host: the host to check
- port: the port to check
- interval: the interval in seconds between health checks
"CMD-SHELL", "nc -z "+host+" "+port+" || exit 1"
func WithTty ¶
func WithTty() create.SetContainerConfig
WithTty allocates a pseudo-TTY for the container
func WithUser ¶
func WithUser(user string) create.SetContainerConfig
WithUser sets the user that commands are run as inside the container
func WithVolume ¶
func WithVolume(volume string) create.SetContainerConfig
WithVolume appends a short hand volume mount point to the container Parameter:
- volume: path where the volume should be mounted
note: will not work within service config for compose file use hc.WithRWHostBindMount or other mount setter functions instead
func WithWorkingDir ¶
func WithWorkingDir(dir string) create.SetContainerConfig
WithWorkingDir sets the working directory for commands to run in
Types ¶
This section is empty.