mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2026-05-04 17:05:17 -04:00
* docs(actions): add templates and examples Agent-Logs-Url: https://github.com/kreuzwerker/terraform-provider-docker/sessions/80969a70-8bde-4ae1-8915-e8945d0d7775 Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com> * docs(actions): regenerate action and buildx docs Agent-Logs-Url: https://github.com/kreuzwerker/terraform-provider-docker/sessions/80969a70-8bde-4ae1-8915-e8945d0d7775 Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Junkern <3775779+Junkern@users.noreply.github.com>
1.8 KiB
1.8 KiB
| page_title | subcategory | description |
|---|---|---|
| docker_exec Action - terraform-provider-docker | Run a command in an existing container, similar to docker container exec. Please note that due to the nature of actions, we cannot have an computed output attribute that contains the command output. |
docker_exec (Action)
Run a command in an existing container, similar to docker container exec. Please note that due to the nature of actions, we cannot have an computed output attribute that contains the command output.
Example Usage
resource "docker_image" "busybox" {
name = "busybox:1.35.0"
}
resource "docker_container" "target" {
name = "docker-exec-example"
image = docker_image.busybox.image_id
must_run = true
command = ["sh", "-c", "sleep 300"]
lifecycle {
action_trigger {
events = [after_create]
actions = [action.docker_exec.create_file]
}
}
}
action "docker_exec" "create_file" {
config {
container = docker_container.target.name
command = ["sh", "-c", "touch /tmp/created-by-action"]
}
}
Schema
Required
command(List of String) Command and arguments to execute inside the container.container(String) Container name or ID where the command is executed.
Optional
detach(Boolean) Run command in the background.env(List of String) Set environment variables for the command (KEY=valueorKEY).env_file(List of String) Read in environment variables from files.privileged(Boolean) Give extended privileges to the command.tty(Boolean) Allocate a pseudo-TTY.user(String) Username or UID (format:<name|uid>[:<group|gid>]).workdir(String) Working directory inside the container.