MCPcopy Create free account
hub / github.com/dagger/dagger / with_exec

Method with_exec

sdk/python/src/dagger/client/gen.py:3050–3128  ·  view source on GitHub ↗

Execute a command in the container, and return a new snapshot of the container state after execution. Parameters ---------- args: Command to execute. Must be valid exec() arguments, not a shell command. Example: ["go", "run", "main.go"].

(
        self,
        args: list[str],
        *,
        use_entrypoint: bool | None = False,
        stdin: str | None = "",
        redirect_stdin: str | None = "",
        redirect_stdout: str | None = "",
        redirect_stderr: str | None = "",
        expect: ReturnType | None = ReturnType.SUCCESS,
        experimental_privileged_nesting: bool | None = False,
        insecure_root_capabilities: bool | None = False,
        expand: bool | None = False,
        no_init: bool | None = False,
    )

Source from the content-addressed store, hash-verified

3048 return Container(_ctx)
3049
3050 def with_exec(
3051 self,
3052 args: list[str],
3053 *,
3054 use_entrypoint: bool | None = False,
3055 stdin: str | None = "",
3056 redirect_stdin: str | None = "",
3057 redirect_stdout: str | None = "",
3058 redirect_stderr: str | None = "",
3059 expect: ReturnType | None = ReturnType.SUCCESS,
3060 experimental_privileged_nesting: bool | None = False,
3061 insecure_root_capabilities: bool | None = False,
3062 expand: bool | None = False,
3063 no_init: bool | None = False,
3064 ) -> Self:
3065 """Execute a command in the container, and return a new snapshot of the
3066 container state after execution.
3067
3068 Parameters
3069 ----------
3070 args:
3071 Command to execute. Must be valid exec() arguments, not a shell
3072 command. Example: ["go", "run", "main.go"].
3073 To run a shell command, execute the shell and pass the shell
3074 command as argument. Example: ["sh", "-c", "ls -l | grep foo"]
3075 Defaults to the container's default arguments (see "defaultArgs"
3076 and "withDefaultArgs").
3077 use_entrypoint:
3078 Apply the OCI entrypoint, if present, by prepending it to the
3079 args. Ignored by default.
3080 stdin:
3081 Content to write to the command's standard input. Example: "Hello
3082 world")
3083 redirect_stdin:
3084 Redirect the command's standard input from a file in the
3085 container. Example: "./stdin.txt"
3086 redirect_stdout:
3087 Redirect the command's standard output to a file in the container.
3088 Example: "./stdout.txt"
3089 redirect_stderr:
3090 Redirect the command's standard error to a file in the container.
3091 Example: "./stderr.txt"
3092 expect:
3093 Exit codes this command is allowed to exit with without error
3094 experimental_privileged_nesting:
3095 Provides Dagger access to the executed command.
3096 insecure_root_capabilities:
3097 Execute the command with all root capabilities. Like --privileged
3098 in Docker
3099 DANGER: this grants the command full access to the host system.
3100 Only use when 1) you trust the command being executed and 2) you
3101 specifically need this level of access.
3102 expand:
3103 Replace "${VAR}" or "$VAR" in the args according to the current
3104 environment variables defined in the container (e.g. "/$VAR/foo").
3105 no_init:
3106 Skip the automatic init process injected into containers by
3107 default.

Callers 15

echoMethod · 0.45
pendingMethod · 0.45
echoMethod · 0.45
commonMethod · 0.45
lintMethod · 0.45
unitMethod · 0.45
passing_checkMethod · 0.45
failing_checkMethod · 0.45
passing_containerMethod · 0.45
failing_containerMethod · 0.45
helloMethod · 0.45
container_echoMethod · 0.45

Calls 3

ArgClass · 0.90
_selectMethod · 0.80
ContainerClass · 0.70

Tested by 10

test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36
test_versionFunction · 0.36