Documentation ¶
Overview ¶
Package exec provides configuration options for executing programs inside containers.
Index ¶
- type Cmd
- type Opt
- func WithCombinedOutput(w io.Writer) Opt
- func WithConsoleSize(width, height uint) Opt
- func WithDemuxedOutput(out io.Writer, err io.Writer) Opt
- func WithEnvVars(vars ...string) Opt
- func WithInput(r io.Reader) Opt
- func WithPrivileged() Opt
- func WithTTY() Opt
- func WithUser(user string) Opt
- func WithWorkingDir(path string) Opt
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶
Opt is a configuration option to run a command inside a container using github.com/thediveo/morbyd.Container.Run.
func WithCombinedOutput ¶
WithCombinedOutput sends the commands's stdout and stderr to the specified io.Writer. This also automatically attaches the commands's stdout and stderr after the command execution context has been created.
func WithConsoleSize ¶
WithConsoleSize sets with width and height of the pseudo TTY; please note the width-height order in contrast to the Docker API order.
func WithDemuxedOutput ¶
WithDemuxedOutput disables the TTY option in order to send the command's stdout and stderr properly separated to the specified out and err io.Writer.
It is a known limitation of the (pseudo) TTY to combine both stdout and stderr of the commands's output streams, and there is no way for Docker (and thus for us) to demultiplex this output sludge after the fact.
func WithEnvVars ¶
WithEnvVars adds multiple environment variables to the container to be started.
func WithInput ¶
WithInput sends input data from the specified io.Reader to the commands's stdin. For this, it allocates a stdin for the command when creating its execution context and then attaches to this stdin after creation.
func WithPrivileged ¶
func WithPrivileged() Opt
WithPrivileged executes the command as privileged inside the container.
func WithTTY ¶
func WithTTY() Opt
WithTTY allocates a pseudo TTY for the commands's input and output.
Please note that using a TTY causes the commands's stdout and stderr streams to get mixed together, so this option can be used only in combination with WithCombinedOutput. Specifying it after WithDemuxedOutput will cause the combined stdout+stderr output to appear only on the specified output io.Writer, whereas the specified error io.Writer won't receive any (error) output at all.
When WithTTY is used before WithDemuxedOutput, it'll become ineffective.
func WithWorkingDir ¶
WithWorkingDir sets the (current) working directory when executing the command inside the container.
type Options ¶
Options represents the plethora of configuration options when running a command inside a container, as well as additional configuration options for handling the output (and optionally input) stream of the command.
Please note that the command to be executed is not passed as an option to github.com/thediveo/morbyd.Container.Exec, but instead as a required Cmd.