# Portainer

> Look after the containers Portainer manages from workflows: read a container's status and recent logs, start, stop, restart and recreate it, redeploy and update stacks, and clear unused images. Start a workflow when a container stops, turns unhealthy or comes back up.

App · 14 actions. Web page: https://docs.lodol.com/docs/integrations/portainer

## Actions

### Get container

Look up a container's status: whether it's running, its health and last health check, exit code, when it started and stopped, restarts, image and ports.

**Inputs**

- Environment (`environment`, text, required): The Docker environment the container is in, as Portainer names it, or its ID.
- Container (`container`, text, required): The container: its name, such as shop-web-1, or its ID (from a trigger or an earlier step).

**Outputs**

- `created` (text): When it was created (UTC)
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `error` (text): Docker's error, if it couldn't start
- `exit_code` (number): The exit code it last stopped with
- `failing_streak` (number): How many health checks in a row have failed
- `finished_at` (text): When it last stopped (UTC); blank if never
- `health` (text): healthy, unhealthy, starting, or none without a health check
- `id` (text): The container's full ID
- `image` (text): Its image, such as nginx:alpine
- `last_health_check` (text): What its last health check printed
- `link` (text): A link to it in Portainer
- `name` (text): Its name
- `networks` (list): The networks it's on
- `oom_killed` (true/false): Whether it was stopped for running out of memory
- `ports` (list): Its published ports, such as 8080->80/tcp
- `restart_count` (number): How many times Docker has restarted it
- `restart_policy` (text): Its restart policy: no, always, unless-stopped or on-failure
- `running` (true/false): Whether it is running
- `service` (text): Its service in that stack, if any
- `short_id` (text): Its short ID, the first 12 characters
- `stack` (text): The stack (Compose project) it belongs to, if any
- `started_at` (text): When it last started (UTC)
- `state` (text): running, exited, restarting, paused, created or dead
- `tty` (true/false): Whether it has a terminal (TTY)

**Example output**

```json
{
  "created": "2026-11-06T21:40:54.987654321Z",
  "environment": "production",
  "environment_id": 1,
  "error": "",
  "exit_code": 0,
  "failing_streak": 0,
  "finished_at": "",
  "health": "healthy",
  "id": "8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "image": "nginx:alpine",
  "last_health_check": "",
  "link": "https://portainer.example.com/#!/1/docker/containers/8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "name": "shop-web-1",
  "networks": [
    "shop_default"
  ],
  "oom_killed": false,
  "ports": [
    "8080->80/tcp"
  ],
  "restart_count": 0,
  "restart_policy": "unless-stopped",
  "running": true,
  "service": "web",
  "short_id": "8e2014789068",
  "stack": "shop",
  "started_at": "2026-11-06T21:40:55.123456789Z",
  "state": "running",
  "tty": false
}
```

### Get container logs

Read a container's recent logs: its last lines, or those since a time, output and errors or one of them, such as to post to a channel when it fails.

**Inputs**

- Environment (`environment`, text, required): The Docker environment the container is in, as Portainer names it, or its ID.
- Container (`container`, text, required): The container: its name, such as shop-web-1, or its ID (from a trigger or an earlier step).
- Lines (`lines`, number): How many of the newest lines. Defaults to 100. From 1 to 5000.
- Since (`since`, text): Only lines written since then: how far back, such as 30m, 2h or 1d, or a date and time such as 2026-11-06 09:00 (UTC).
- Which lines (`stream`, text): Output, errors, or both. Defaults to both. One of: `both` (Output and errors), `stdout` (Output only (stdout)), `stderr` (Errors only (stderr)). Default: `both`.
- Show times (`timestamps`, true/false): Start each line with when it was written (UTC). Default: `false`.

**Outputs**

- `container` (text): The container's name
- `container_id` (text): Its full ID
- `environment` (text): The environment's name
- `line_count` (number): How many lines there are
- `lines` (list): The lines, oldest first
- `logs` (text): The lines, oldest first, as one text
- `state` (text): Its state now, such as running or exited
- `truncated` (true/false): Whether the text was cut, keeping the newest lines

**Example output**

```json
{
  "container": "shop-web-1",
  "container_id": "8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "environment": "production",
  "line_count": 2,
  "lines": [
    {
      "stream": "stdout",
      "text": "GET /health 200",
      "time": "2026-11-06T23:50:33.624849099Z"
    },
    {
      "stream": "stderr",
      "text": "upstream timed out (110: Connection timed out)",
      "time": "2026-11-06T23:50:35.625963482Z"
    }
  ],
  "logs": "GET /health 200\nupstream timed out (110: Connection timed out)",
  "state": "running",
  "truncated": false
}
```

### List containers

List the containers in an environment, running and stopped, by state, name or stack, with their status, health and image.

**Inputs**

- Environment (`environment`, text, required): The Docker environment, as Portainer names it, or its ID.
- State (`state`, text): Only containers in this state. Leave blank for every one. One of: `running`, `exited` (Stopped (exited)), `restarting`, `paused`, `created` (Created, never started), `dead`.
- Name or image (`search`, text): Only containers whose name or image has these words, such as web.
- Stack (`stack`, text): Only containers of this stack (Compose project), by name.
- How many (`limit`, number): The most to list. Defaults to 50. From 1 to 500.

**Outputs**

- `containers` (list): The containers, by name
- `count` (number): How many are listed
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `total` (number): How many match in all

**Example output**

```json
{
  "containers": [
    {
      "created": "2026-11-06T21:40:54Z",
      "environment": "production",
      "environment_id": 1,
      "exit_code": 0,
      "health": "none",
      "id": "8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
      "image": "nginx:alpine",
      "link": "https://portainer.example.com/#!/1/docker/containers/8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
      "name": "shop-web-1",
      "ports": [
        "8080->80/tcp"
      ],
      "service": "web",
      "short_id": "8e2014789068",
      "stack": "shop",
      "state": "running",
      "status": "Up 2 hours"
    }
  ],
  "count": 1,
  "environment": "production",
  "environment_id": 1,
  "total": 1
}
```

### List environments

List the Docker and Kubernetes environments Portainer manages, with whether each is up and how many containers are running, stopped and unhealthy.

**Inputs**

- Search (`search`, text): Words in the name or address.
- How many (`limit`, number): The most to list. Defaults to 50. From 1 to 500.

**Outputs**

- `count` (number): How many are listed
- `environments` (list): The environments, by name
- `total` (number): How many match in all

**Example output**

```json
{
  "count": 1,
  "environments": [
    {
      "checked_at": "2026-11-06T23:47:12Z",
      "containers": 12,
      "docker_version": "29.9.3",
      "healthy": 4,
      "id": 1,
      "images": 18,
      "link": "https://portainer.example.com/#!/1/docker/dashboard",
      "name": "production",
      "platform": "docker",
      "public_url": "",
      "running": 11,
      "stacks": 3,
      "status": "up",
      "stopped": 1,
      "type": "Docker",
      "unhealthy": 0,
      "url": "unix:///var/run/docker.sock"
    }
  ],
  "total": 1
}
```

### List stacks

List the stacks Portainer deploys, in every environment or one, with whether each is running, its Git repository and commit, and when it last changed.

**Inputs**

- Environment (`environment`, text): Only stacks in this environment. Leave blank for every one.
- Search (`search`, text): Words in the stack's name.
- How many (`limit`, number): The most to list. Defaults to 50. From 1 to 500.

**Outputs**

- `count` (number): How many are listed
- `stacks` (list): The stacks, by name
- `total` (number): How many match in all

**Example output**

```json
{
  "count": 1,
  "stacks": [
    {
      "auto_update": false,
      "compose_file": "docker-compose.yml",
      "created": "2026-11-06T23:52:52Z",
      "created_by": "admin",
      "env_names": [
        "APP_VERSION"
      ],
      "environment": "production",
      "environment_id": 1,
      "from_git": true,
      "git_commit": "2ce3eefe292f029fb23c07a82c8308c429dd70b3",
      "git_reference": "refs/heads/main",
      "git_url": "https://github.com/example/shop",
      "id": 2,
      "link": "https://portainer.example.com/#!/1/docker/stacks/shop?id=2&type=2&regular=true&orphaned=false&orphanedRunning=false",
      "message": "",
      "name": "shop",
      "status": "active",
      "type": "compose",
      "updated": "2026-11-06T23:53:12Z",
      "updated_by": "admin"
    }
  ],
  "total": 1
}
```

### Recreate container

Replace a container with a new one from the same settings, pulling the newest image of its tag first, to update it. It gets a new ID.

**Inputs**

- Environment (`environment`, text, required): The Docker environment the container is in, as Portainer names it, or its ID.
- Container (`container`, text, required): The container: its name, such as shop-web-1, or its ID (from a trigger or an earlier step).
- Pull the newest image (`pull_image`, true/false): Pull the newest version of its image's tag first. Off recreates it from the image already on the server. Default: `true`.

**Outputs**

- `created` (text): When it was created (UTC)
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `error` (text): Docker's error, if it couldn't start
- `exit_code` (number): The exit code it last stopped with
- `failing_streak` (number): How many health checks in a row have failed
- `finished_at` (text): When it last stopped (UTC); blank if never
- `health` (text): healthy, unhealthy, starting, or none without a health check
- `id` (text): The container's full ID
- `image` (text): Its image, such as nginx:alpine
- `image_changed` (true/false): Whether the new container runs a newer image
- `image_id` (text): The image the new container runs
- `last_health_check` (text): What its last health check printed
- `link` (text): A link to it in Portainer
- `name` (text): Its name
- `networks` (list): The networks it's on
- `oom_killed` (true/false): Whether it was stopped for running out of memory
- `ports` (list): Its published ports, such as 8080->80/tcp
- `previous_id` (text): The old container's ID; the new one has a new ID
- `previous_image_id` (text): The image the old container ran
- `pulled` (true/false): Whether the image was pulled first
- `restart_count` (number): How many times Docker has restarted it
- `restart_policy` (text): Its restart policy: no, always, unless-stopped or on-failure
- `running` (true/false): Whether it is running
- `service` (text): Its service in that stack, if any
- `short_id` (text): Its short ID, the first 12 characters
- `stack` (text): The stack (Compose project) it belongs to, if any
- `started_at` (text): When it last started (UTC)
- `state` (text): running, exited, restarting, paused, created or dead
- `tty` (true/false): Whether it has a terminal (TTY)

**Example output**

```json
{
  "created": "2026-11-06T21:40:54.987654321Z",
  "environment": "production",
  "environment_id": 1,
  "error": "",
  "exit_code": 0,
  "failing_streak": 0,
  "finished_at": "",
  "health": "healthy",
  "id": "11517112ac62230b49c7ae1836aea4c8db2119c749a74f7c976f33b1d93dd716",
  "image": "nginx:alpine",
  "image_changed": true,
  "image_id": "sha256:9a1b3c5d7e9f2b4d6f8a0c2e4a6c8e0b2d4f6a8c0e2b4d6f8a0c2e4b6d8f0a2c",
  "last_health_check": "",
  "link": "https://portainer.example.com/#!/1/docker/containers/11517112ac62230b49c7ae1836aea4c8db2119c749a74f7c976f33b1d93dd716",
  "name": "shop-web-1",
  "networks": [
    "shop_default"
  ],
  "oom_killed": false,
  "ports": [
    "8080->80/tcp"
  ],
  "previous_id": "8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "previous_image_id": "sha256:713fc2ebfd92e8217db451477182ee91944b123d2b1ee9fd5a8c6e91ca6c3a11",
  "pulled": true,
  "restart_count": 0,
  "restart_policy": "unless-stopped",
  "running": true,
  "service": "web",
  "short_id": "11517112ac62",
  "stack": "shop",
  "started_at": "2026-11-06T21:40:55.123456789Z",
  "state": "running",
  "tty": false
}
```

### Redeploy stack

Redeploy a stack: one from Git with its newest commit, one made in Portainer as it is, optionally pulling newer images and setting environment variables.

**Inputs**

- Stack (`stack`, text, required): The stack: its name, such as shop, or its ID.
- Environment (`environment`, text): The environment the stack is in. Only needed when two environments have a stack of that name.
- Pull newer images (`pull_images`, true/false): Pull the newest version of each image's tag before deploying. Off uses the images already on the server. Default: `false`.
- Environment variables (`environment_variables`, text): Variables to set, one per line, such as APP_VERSION=1.4.2. Each replaces the stack's variable of that name or is added; the rest stay as they are.
- Remove old services (`prune`, true/false): Remove services that are no longer in the compose file. Leave blank to keep the stack's own setting.

**Outputs**

- `auto_update` (true/false): Whether Portainer redeploys it by itself (GitOps updates)
- `changed_variables` (list): The environment variables set
- `compose_file` (text): The compose file's path, such as docker-compose.yml
- `created` (text): When it was made (UTC)
- `created_by` (text): Who made it
- `env_names` (list): The names of its environment variables
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `from_git` (true/false): Whether it is deployed from a Git repository
- `git_commit` (text): The commit it is deployed from, if from Git
- `git_reference` (text): The branch or tag it follows, such as refs/heads/main
- `git_url` (text): The Git repository, if from Git
- `id` (number): The stack's ID, for other Portainer steps
- `link` (text): A link to it in Portainer
- `message` (text): Why its last deployment failed, if it did
- `name` (text): Its name
- `previous_git_commit` (text): The commit it was deployed from before
- `pulled_images` (true/false): Whether newer images were pulled first
- `status` (text): active, inactive, deploying or failed
- `type` (text): compose, swarm or kubernetes
- `updated` (text): When it was last changed (UTC); blank if never
- `updated_by` (text): Who last changed it

**Example output**

```json
{
  "auto_update": false,
  "changed_variables": [
    "APP_VERSION"
  ],
  "compose_file": "docker-compose.yml",
  "created": "2026-11-06T23:52:52Z",
  "created_by": "admin",
  "env_names": [
    "APP_VERSION"
  ],
  "environment": "production",
  "environment_id": 1,
  "from_git": true,
  "git_commit": "2ce3eefe292f029fb23c07a82c8308c429dd70b3",
  "git_reference": "refs/heads/main",
  "git_url": "https://github.com/example/shop",
  "id": 2,
  "link": "https://portainer.example.com/#!/1/docker/stacks/shop?id=2&type=2&regular=true&orphaned=false&orphanedRunning=false",
  "message": "",
  "name": "shop",
  "previous_git_commit": "62fce2b5efcc5072e83e60e0830cae98b0aaf32d",
  "pulled_images": false,
  "status": "active",
  "type": "compose",
  "updated": "2026-11-06T23:53:12Z",
  "updated_by": "admin"
}
```

### Remove unused images

Free disk space by removing images no container uses: untagged ones, or every unused one, optionally only those older than some hours.

**Inputs**

- Environment (`environment`, text, required): The Docker environment, as Portainer names it, or its ID.
- Only untagged images (`only_untagged`, true/false): Remove only images without a tag (old versions left behind by updates). Off removes every image no container uses. Default: `true`.
- Older than (hours) (`older_than_hours`, number): Only images made more than this many hours ago, such as 168 for a week. At least 1.

**Outputs**

- `deleted` (list): The removed images' IDs
- `environment` (text): The environment's name
- `images_deleted` (number): How many images were removed
- `only_untagged` (true/false): Whether only untagged images were removed
- `space_reclaimed` (text): How much disk space was freed, such as 1.2 GB
- `space_reclaimed_bytes` (number): How much disk space was freed, in bytes
- `untagged` (list): The tags taken off, such as nginx:1.27

**Example output**

```json
{
  "deleted": [
    "sha256:5b0f8c2a7e1d4c3b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e4d3c2b1a0f9e8d7c6b"
  ],
  "environment": "production",
  "images_deleted": 1,
  "only_untagged": true,
  "space_reclaimed": "50.0 MB",
  "space_reclaimed_bytes": 52428800,
  "untagged": []
}
```

### Restart container

Restart a container, such as when it stops answering, from an alert or a chat command. A stopped one is started.

**Inputs**

- Environment (`environment`, text, required): The Docker environment the container is in, as Portainer names it, or its ID.
- Container (`container`, text, required): The container: its name, such as shop-web-1, or its ID (from a trigger or an earlier step).
- Seconds to wait (`wait_seconds`, number): How long to let it shut down before it's forced to. Defaults to 10. From 0 to 600.

**Outputs**

- `changed` (true/false): False when it already was so, and nothing was done
- `created` (text): When it was created (UTC)
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `error` (text): Docker's error, if it couldn't start
- `exit_code` (number): The exit code it last stopped with
- `failing_streak` (number): How many health checks in a row have failed
- `finished_at` (text): When it last stopped (UTC); blank if never
- `health` (text): healthy, unhealthy, starting, or none without a health check
- `id` (text): The container's full ID
- `image` (text): Its image, such as nginx:alpine
- `last_health_check` (text): What its last health check printed
- `link` (text): A link to it in Portainer
- `name` (text): Its name
- `networks` (list): The networks it's on
- `oom_killed` (true/false): Whether it was stopped for running out of memory
- `ports` (list): Its published ports, such as 8080->80/tcp
- `restart_count` (number): How many times Docker has restarted it
- `restart_policy` (text): Its restart policy: no, always, unless-stopped or on-failure
- `running` (true/false): Whether it is running
- `service` (text): Its service in that stack, if any
- `short_id` (text): Its short ID, the first 12 characters
- `stack` (text): The stack (Compose project) it belongs to, if any
- `started_at` (text): When it last started (UTC)
- `state` (text): running, exited, restarting, paused, created or dead
- `tty` (true/false): Whether it has a terminal (TTY)

**Example output**

```json
{
  "changed": true,
  "created": "2026-11-06T21:40:54.987654321Z",
  "environment": "production",
  "environment_id": 1,
  "error": "",
  "exit_code": 0,
  "failing_streak": 0,
  "finished_at": "",
  "health": "healthy",
  "id": "8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "image": "nginx:alpine",
  "last_health_check": "",
  "link": "https://portainer.example.com/#!/1/docker/containers/8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "name": "shop-web-1",
  "networks": [
    "shop_default"
  ],
  "oom_killed": false,
  "ports": [
    "8080->80/tcp"
  ],
  "restart_count": 0,
  "restart_policy": "unless-stopped",
  "running": true,
  "service": "web",
  "short_id": "8e2014789068",
  "stack": "shop",
  "started_at": "2026-11-06T21:40:55.123456789Z",
  "state": "running",
  "tty": false
}
```

### Start container

Start a stopped container. One already running is left as it is.

**Inputs**

- Environment (`environment`, text, required): The Docker environment the container is in, as Portainer names it, or its ID.
- Container (`container`, text, required): The container: its name, such as shop-web-1, or its ID (from a trigger or an earlier step).

**Outputs**

- `changed` (true/false): False when it already was so, and nothing was done
- `created` (text): When it was created (UTC)
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `error` (text): Docker's error, if it couldn't start
- `exit_code` (number): The exit code it last stopped with
- `failing_streak` (number): How many health checks in a row have failed
- `finished_at` (text): When it last stopped (UTC); blank if never
- `health` (text): healthy, unhealthy, starting, or none without a health check
- `id` (text): The container's full ID
- `image` (text): Its image, such as nginx:alpine
- `last_health_check` (text): What its last health check printed
- `link` (text): A link to it in Portainer
- `name` (text): Its name
- `networks` (list): The networks it's on
- `oom_killed` (true/false): Whether it was stopped for running out of memory
- `ports` (list): Its published ports, such as 8080->80/tcp
- `restart_count` (number): How many times Docker has restarted it
- `restart_policy` (text): Its restart policy: no, always, unless-stopped or on-failure
- `running` (true/false): Whether it is running
- `service` (text): Its service in that stack, if any
- `short_id` (text): Its short ID, the first 12 characters
- `stack` (text): The stack (Compose project) it belongs to, if any
- `started_at` (text): When it last started (UTC)
- `state` (text): running, exited, restarting, paused, created or dead
- `tty` (true/false): Whether it has a terminal (TTY)

**Example output**

```json
{
  "changed": true,
  "created": "2026-11-06T21:40:54.987654321Z",
  "environment": "production",
  "environment_id": 1,
  "error": "",
  "exit_code": 0,
  "failing_streak": 0,
  "finished_at": "",
  "health": "healthy",
  "id": "8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "image": "nginx:alpine",
  "last_health_check": "",
  "link": "https://portainer.example.com/#!/1/docker/containers/8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "name": "shop-web-1",
  "networks": [
    "shop_default"
  ],
  "oom_killed": false,
  "ports": [
    "8080->80/tcp"
  ],
  "restart_count": 0,
  "restart_policy": "unless-stopped",
  "running": true,
  "service": "web",
  "short_id": "8e2014789068",
  "stack": "shop",
  "started_at": "2026-11-06T21:40:55.123456789Z",
  "state": "running",
  "tty": false
}
```

### Start stack

Start a stopped stack's containers. One already running is left as it is.

**Inputs**

- Stack (`stack`, text, required): The stack: its name, such as shop, or its ID.
- Environment (`environment`, text): The environment the stack is in. Only needed when two environments have a stack of that name.

**Outputs**

- `auto_update` (true/false): Whether Portainer redeploys it by itself (GitOps updates)
- `changed` (true/false): False when it already was so, and nothing was done
- `compose_file` (text): The compose file's path, such as docker-compose.yml
- `created` (text): When it was made (UTC)
- `created_by` (text): Who made it
- `env_names` (list): The names of its environment variables
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `from_git` (true/false): Whether it is deployed from a Git repository
- `git_commit` (text): The commit it is deployed from, if from Git
- `git_reference` (text): The branch or tag it follows, such as refs/heads/main
- `git_url` (text): The Git repository, if from Git
- `id` (number): The stack's ID, for other Portainer steps
- `link` (text): A link to it in Portainer
- `message` (text): Why its last deployment failed, if it did
- `name` (text): Its name
- `previous_git_commit` (text): The commit it was deployed from before
- `status` (text): active, inactive, deploying or failed
- `type` (text): compose, swarm or kubernetes
- `updated` (text): When it was last changed (UTC); blank if never
- `updated_by` (text): Who last changed it

**Example output**

```json
{
  "auto_update": false,
  "changed": true,
  "compose_file": "docker-compose.yml",
  "created": "2026-11-06T23:52:52Z",
  "created_by": "admin",
  "env_names": [
    "APP_VERSION"
  ],
  "environment": "production",
  "environment_id": 1,
  "from_git": true,
  "git_commit": "2ce3eefe292f029fb23c07a82c8308c429dd70b3",
  "git_reference": "refs/heads/main",
  "git_url": "https://github.com/example/shop",
  "id": 2,
  "link": "https://portainer.example.com/#!/1/docker/stacks/shop?id=2&type=2&regular=true&orphaned=false&orphanedRunning=false",
  "message": "",
  "name": "shop",
  "previous_git_commit": "2ce3eefe292f029fb23c07a82c8308c429dd70b3",
  "status": "active",
  "type": "compose",
  "updated": "2026-11-06T23:53:12Z",
  "updated_by": "admin"
}
```

### Stop container

Stop a running container, letting it shut down first. One already stopped is left as it is.

**Inputs**

- Environment (`environment`, text, required): The Docker environment the container is in, as Portainer names it, or its ID.
- Container (`container`, text, required): The container: its name, such as shop-web-1, or its ID (from a trigger or an earlier step).
- Seconds to wait (`wait_seconds`, number): How long to let it shut down before it's forced to. Defaults to 10. From 0 to 600.

**Outputs**

- `changed` (true/false): False when it already was so, and nothing was done
- `created` (text): When it was created (UTC)
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `error` (text): Docker's error, if it couldn't start
- `exit_code` (number): The exit code it last stopped with
- `failing_streak` (number): How many health checks in a row have failed
- `finished_at` (text): When it last stopped (UTC); blank if never
- `health` (text): healthy, unhealthy, starting, or none without a health check
- `id` (text): The container's full ID
- `image` (text): Its image, such as nginx:alpine
- `last_health_check` (text): What its last health check printed
- `link` (text): A link to it in Portainer
- `name` (text): Its name
- `networks` (list): The networks it's on
- `oom_killed` (true/false): Whether it was stopped for running out of memory
- `ports` (list): Its published ports, such as 8080->80/tcp
- `restart_count` (number): How many times Docker has restarted it
- `restart_policy` (text): Its restart policy: no, always, unless-stopped or on-failure
- `running` (true/false): Whether it is running
- `service` (text): Its service in that stack, if any
- `short_id` (text): Its short ID, the first 12 characters
- `stack` (text): The stack (Compose project) it belongs to, if any
- `started_at` (text): When it last started (UTC)
- `state` (text): running, exited, restarting, paused, created or dead
- `tty` (true/false): Whether it has a terminal (TTY)

**Example output**

```json
{
  "changed": true,
  "created": "2026-11-06T21:40:54.987654321Z",
  "environment": "production",
  "environment_id": 1,
  "error": "",
  "exit_code": 0,
  "failing_streak": 0,
  "finished_at": "",
  "health": "healthy",
  "id": "8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "image": "nginx:alpine",
  "last_health_check": "",
  "link": "https://portainer.example.com/#!/1/docker/containers/8e2014789068049ac9367041896c9de6cb4c11c24ae84946b7414111e4954539",
  "name": "shop-web-1",
  "networks": [
    "shop_default"
  ],
  "oom_killed": false,
  "ports": [
    "8080->80/tcp"
  ],
  "restart_count": 0,
  "restart_policy": "unless-stopped",
  "running": true,
  "service": "web",
  "short_id": "8e2014789068",
  "stack": "shop",
  "started_at": "2026-11-06T21:40:55.123456789Z",
  "state": "running",
  "tty": false
}
```

### Stop stack

Stop a stack's containers, keeping the stack to start again later. One already stopped is left as it is.

**Inputs**

- Stack (`stack`, text, required): The stack: its name, such as shop, or its ID.
- Environment (`environment`, text): The environment the stack is in. Only needed when two environments have a stack of that name.

**Outputs**

- `auto_update` (true/false): Whether Portainer redeploys it by itself (GitOps updates)
- `changed` (true/false): False when it already was so, and nothing was done
- `compose_file` (text): The compose file's path, such as docker-compose.yml
- `created` (text): When it was made (UTC)
- `created_by` (text): Who made it
- `env_names` (list): The names of its environment variables
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `from_git` (true/false): Whether it is deployed from a Git repository
- `git_commit` (text): The commit it is deployed from, if from Git
- `git_reference` (text): The branch or tag it follows, such as refs/heads/main
- `git_url` (text): The Git repository, if from Git
- `id` (number): The stack's ID, for other Portainer steps
- `link` (text): A link to it in Portainer
- `message` (text): Why its last deployment failed, if it did
- `name` (text): Its name
- `previous_git_commit` (text): The commit it was deployed from before
- `status` (text): active, inactive, deploying or failed
- `type` (text): compose, swarm or kubernetes
- `updated` (text): When it was last changed (UTC); blank if never
- `updated_by` (text): Who last changed it

**Example output**

```json
{
  "auto_update": false,
  "changed": true,
  "compose_file": "docker-compose.yml",
  "created": "2026-11-06T23:52:52Z",
  "created_by": "admin",
  "env_names": [
    "APP_VERSION"
  ],
  "environment": "production",
  "environment_id": 1,
  "from_git": true,
  "git_commit": "2ce3eefe292f029fb23c07a82c8308c429dd70b3",
  "git_reference": "refs/heads/main",
  "git_url": "https://github.com/example/shop",
  "id": 2,
  "link": "https://portainer.example.com/#!/1/docker/stacks/shop?id=2&type=2&regular=true&orphaned=false&orphanedRunning=false",
  "message": "",
  "name": "shop",
  "previous_git_commit": "2ce3eefe292f029fb23c07a82c8308c429dd70b3",
  "status": "active",
  "type": "compose",
  "updated": "2026-11-06T23:53:12Z",
  "updated_by": "admin"
}
```

### Update stack

Change a stack's compose file, or set or remove its environment variables, and redeploy it. A stack from Git takes only variables; its file comes from the repository.

**Inputs**

- Stack (`stack`, text, required): The stack: its name, such as shop, or its ID.
- Environment (`environment`, text): The environment the stack is in. Only needed when two environments have a stack of that name.
- Compose file (`compose_file`, text): The whole new compose file (docker-compose.yml). Leave blank to keep it.
- Environment variables (`environment_variables`, text): Variables to set, one per line, such as APP_VERSION=1.4.2. Each replaces the stack's variable of that name or is added; the rest stay as they are.
- Remove variables (`remove_variables`, text): Names of variables to take off the stack, one per line, such as OLD_FLAG.
- Pull newer images (`pull_images`, true/false): Pull the newest version of each image's tag before deploying. Off uses the images already on the server. Default: `false`.
- Remove old services (`prune`, true/false): Remove services that are no longer in the compose file. Leave blank to keep the stack's own setting.

**Outputs**

- `auto_update` (true/false): Whether Portainer redeploys it by itself (GitOps updates)
- `changed_variables` (list): The environment variables set
- `compose_file` (text): The compose file's path, such as docker-compose.yml
- `compose_file_changed` (true/false): Whether a new compose file was given
- `created` (text): When it was made (UTC)
- `created_by` (text): Who made it
- `env_names` (list): The names of its environment variables
- `environment` (text): The environment's name
- `environment_id` (number): The environment's ID
- `from_git` (true/false): Whether it is deployed from a Git repository
- `git_commit` (text): The commit it is deployed from, if from Git
- `git_reference` (text): The branch or tag it follows, such as refs/heads/main
- `git_url` (text): The Git repository, if from Git
- `id` (number): The stack's ID, for other Portainer steps
- `link` (text): A link to it in Portainer
- `message` (text): Why its last deployment failed, if it did
- `name` (text): Its name
- `previous_git_commit` (text): The commit it was deployed from before
- `pulled_images` (true/false): Whether newer images were pulled first
- `removed_variables` (list): The environment variables removed
- `status` (text): active, inactive, deploying or failed
- `type` (text): compose, swarm or kubernetes
- `updated` (text): When it was last changed (UTC); blank if never
- `updated_by` (text): Who last changed it

**Example output**

```json
{
  "auto_update": false,
  "changed_variables": [
    "APP_VERSION"
  ],
  "compose_file": "docker-compose.yml",
  "compose_file_changed": true,
  "created": "2026-11-06T23:52:52Z",
  "created_by": "admin",
  "env_names": [
    "APP_VERSION"
  ],
  "environment": "production",
  "environment_id": 1,
  "from_git": false,
  "git_commit": "",
  "git_reference": "",
  "git_url": "",
  "id": 2,
  "link": "https://portainer.example.com/#!/1/docker/stacks/shop?id=2&type=2&regular=true&orphaned=false&orphanedRunning=false",
  "message": "",
  "name": "shop",
  "previous_git_commit": "",
  "pulled_images": false,
  "removed_variables": [
    "OLD_FLAG"
  ],
  "status": "active",
  "type": "compose",
  "updated": "2026-11-06T23:53:12Z",
  "updated_by": "admin"
}
```
