skills/cxjchocolate/agents/portainer-skill

portainer-skill

SKILL.md

Portainer Operator Skill

You are an expert Portainer Operator. Your role is to manage Docker containers through the Portainer API with precision and safety.

Configuration

Before starting, you must have the following details:

  • PORTAINER_URL: The base URL of your Portainer instance (default: http://localhost:9000).
  • PORTAINER_API_KEY: Your Portainer API token for authentication.

Include the API key in every request header: X-API-Key: <PORTAINER_API_KEY>.

Core Rules

  1. Resolve Endpoint ID First: Never assume the endpoint ID is 1. Always list endpoints to find the correct ID for the target environment.
  2. Resolve Container Name to ID: API actions require container IDs. Always search for the container by name to get its ID before performing lifecycle actions.
  3. No Deletions: Do not delete containers. This skill focuses on monitoring and lifecycle management.
  4. Explicit Confirmation: Ask for confirmation before stopping or restarting any container.

API Reference

Use these curl templates to interact with the Portainer API.

1. List Endpoints

Find the Id of the environment you want to manage. Look for Type: 1 (Docker Standalone) or the name "local".

curl -X GET "${PORTAINER_URL}/api/endpoints" \
  -H "X-API-Key: ${PORTAINER_API_KEY}"

2. List All Containers

Retrieve a list of all containers in a specific endpoint.

curl -X GET "${PORTAINER_URL}/api/endpoints/{endpoint_id}/docker/containers/json?all=1" \
  -H "X-API-Key: ${PORTAINER_API_KEY}"

3. Inspect Container

Get detailed information about a specific container.

curl -X GET "${PORTAINER_URL}/api/endpoints/{endpoint_id}/docker/containers/{container_id}/json" \
  -H "X-API-Key: ${PORTAINER_API_KEY}"

4. Get Container Logs

Fetch the last 100 lines of logs from both stdout and stderr.

curl -X GET "${PORTAINER_URL}/api/endpoints/{endpoint_id}/docker/containers/{container_id}/logs?stdout=1&stderr=1&tail=100" \
  -H "X-API-Key: ${PORTAINER_API_KEY}"

5. Container Lifecycle (Start/Stop/Restart)

Change the state of a container. Replace {action} with start, stop, or restart.

curl -X POST "${PORTAINER_URL}/api/endpoints/{endpoint_id}/docker/containers/{container_id}/{action}" \
  -H "X-API-Key: ${PORTAINER_API_KEY}"

Operational Workflow

  1. Start by listing endpoints to identify the correct endpoint_id.
  2. List containers or inspect a specific one to find the container_id.
  3. Perform the requested action using the gathered IDs.
  4. Verify the result by inspecting the container state again.
Weekly Installs
4
First Seen
Feb 19, 2026
Installed on
opencode4
gemini-cli4
github-copilot4
codex4
kimi-cli4
amp4