What you’ll see
Portainer
- Containers: every container as a dot, under Needs attention, Healthy, No health check and Stopped. A dot is red for an unhealthy container, one that exited with an error code, or one on your keep-running list that isn’t running. It’s orange while one restarts, and for 10 minutes after one that’s been around a while starts again, whether it crashed or you restarted it: that’s how a container that keeps crashing shows. A container that was stopped cleanly is grey and never counts as a problem, unless it’s on your keep-running list. Each dot opens that container’s page.
- Running: how many containers were running, over the last day.
- Docker: how many containers, in how many compose projects; the images, the space they take and how much of it belongs only to images no container uses; the Docker version, CPUs and memory; the volumes and the networks. Remove unused images in its corner asks first, then frees at least that much; the images can be pulled again.
Container
One page for every container, titled with its name.
- how it stands now, with Start, Stop, Restart and Pull and recreate (the newest image, the same settings) in the card’s corner;
- its CPU and memory over the last hour, and its state over the last day;
- Open: a link to each port it publishes, on your environment’s Public IP, or to its
homepage.hreflabel; - Logs: its last 10 log lines, errors marked;
- its image, compose project, restart policy, restarts and when it last started, its last four health checks, and its mounts.
Stop never shows for a container on your keep-running list. Without the list, every container has Stop.
Status
- Watches every container.
- Red for an unhealthy container, one that exited with an error, or one on your keep-running list that isn’t running.
- Orange while one restarts, for 10 minutes after one starts again, or while its health check is starting.
- A container stopped cleanly never counts as a problem, unless it’s on your keep-running list.
- Red once Portainer stops answering.
- Notifies you when it turns orange or red.
How it connects
The pages read Portainer CE’s API with your access token, sent as X-API-Key. Requests for containers go through Portainer to Docker on your host.
Requests it makes on its own 9
- GET
/api/endpoints/1/docker/containers/json?all=1 Every container, its state and Docker’s own status words. The page shows up to 60, and says so when there are more.
PortainerOnce a minute
- GET
/api/docker/1/dashboardHow many containers, images, volumes, networks and compose projects.
PortainerEvery 15 minutes
- GET
/api/endpoints/1The Docker version, CPUs and memory.
PortainerEvery 15 minutes
- GET
/api/endpoints/1/docker/system/dfWhich images no container uses, and their size.
PortainerEvery 15 minutes
- GET
/api/system/versionWhether a newer Portainer is out. Portainer asks GitHub each time, so it’s hourly.
PortainerEvery hour
- GET
/api/endpoints/{param.env}/docker/containers/{param.id}/jsonThe container’s state, health checks, restarts, ports and mounts.
ContainerOnce a minute while open
- GET
/api/endpoints/{param.env}The environment’s Public IP, for the port links.
ContainerOnce a minute while open
- GET
/api/endpoints/{param.env}/docker/containers/{param.id}/stats?stream=false Its CPU and memory.
ContainerOnce a minute while open
- GET
/api/endpoints/{param.env}/docker/containers/{param.id}/logs?stdout=1 &stderr=1 &tail=20 ×tamps=1 Its latest log lines.
ContainerOnce a minute while open
Requests it makes when you act 5
- POST
/api/endpoints/1/docker/images/prune?filters=%7B%22dangling%22%3A%7B%22false%22%3Atrue%7D%7D Removes every image no container uses.
PortainerWhen you press Remove unused images and confirm
- POST
/api/endpoints/{param.env}/docker/containers/{param.id}/startStarts the container.
ContainerWhen you press Start and confirm
- POST
/api/endpoints/{param.env}/docker/containers/{param.id}/stop?t=10 Stops it.
ContainerWhen you press Stop and confirm
- POST
/api/endpoints/{param.env}/docker/containers/{param.id}/restart?t=10 Restarts it.
ContainerWhen you press Restart and confirm
- POST
/api/docker/{param.env}/containers/{answer.c.Id}/recreatePulls the newest image and recreates the container with the same settings.
ContainerWhen you press Pull and recreate and confirm
That’s about 75 requests an hour with the Portainer page open, plus 240 an hour while a container’s page is open. Legato also keeps each container’s state every 5 minutes in History, for its page’s day.
Sources and buttons explains each part of a page.
Set it up
- Make an access token. In Portainer, open My account → Access tokens → Add access token, as an administrator. Portainer CE has no read-only role, so a token can also stop and remove containers: keep it to Legato.
- Save it in Legato. In Settings → Secrets, save the token under
portainer, bound to your Portainer’s address. You can also link a 1Password reference. - List what must keep running (optional). In Settings → Lists, add a list called
keep-runningwith the containers you never want to stop by accident, such as your reverse proxy and DNS. Their Stop button never shows. - Add the pages. Paste the prompt into your agent, or download the two pages and run
/Applications/Legato.app/Contents/Helpers/legato set portainer-container portainer-container.json, thenlegato set portainer portainer.json. Keep the IDportainer-container: every dot and row opens it. - Give your environment a Public IP (optional). In Portainer, open Environments, choose yours and fill in Public IP with your host’s address. Each container’s page then links to the ports it publishes.
- Point them at Portainer. Change
https://portainer.example.comto your Portainer’s address on every source, and the environment id1on the Portainer page to yours: it’s the number in Portainer’s address when you open your environment (#!/3/docker/dashboardis 3).
The cards fill within a minute. A mistyped token is the usual reason they don’t: the page then notes that Portainer refused it.
Prompt for your agent
Add 2 Legato pages for Portainer, starting from https://legatobar.com/examples/portainer.json, https://legatobar.com/examples/portainer-container.json. Use the page IDs portainer, portainer-container if they’re free: the pages link to each other by those IDs, so with any other ID, change the matching legato://page/ links.
Add the pages as they are, keeping their page IDs. Change https://portainer.example.com on every source of both pages to my Portainer’s address, and the environment id 1 on the Portainer page to mine. I’ll save my access token as portainer in Settings → Secrets, and add a keep-running list in Settings → Lists, myself. Don’t press Start, Stop, Restart, Pull and recreate or Remove unused images to test them.
Use the local Legato MCP tools or /Applications/Legato.app/Contents/Helpers/legato.
Use list_pages first and choose an unused page ID. Do not overwrite an existing page. If I explicitly ask to update one, read its full body with get_page, preserve unrelated cards and settings, and use if_match with that version. On version_mismatch, read again before merging.
Ask me only for non-secret setup details that are missing. Never ask me to paste a password, token or API key into chat, page JSON or command arguments. Tell me to save it in Settings → Secrets for the service host, or link it from 1Password there.
Use the downloadable page, not the illustration’s sample data. Never invent readings. Fix any invalid_page paths and verify that the page loads. Do not press buttons that change the service or real devices to test it.Download the pages
Questions
Why does a stopped container sometimes not count as a problem?
Docker tells a clean stop (exit code 0) from a crash. A container that stopped cleanly, such as a one-off job, is grey. One that exited with an error, or one on your keep-running list, is red.
Why can’t I see when an image has an update?
Portainer CE doesn’t check: that’s in Portainer’s Business Edition, so the pages can’t show it.
Does Spotlight ask before it removes images?
No. Spotlight presses a button you choose by name without asking, as it does for every button, so Remove unused images goes straight through from there. The images can be pulled again. Start, Stop, Restart and Pull and recreate aren’t in Spotlight, since it couldn’t say which container they’d act on.
Does it work with several Docker hosts?
The Portainer page shows one environment. For another, add a copy of the page with its own ID, that environment’s id in its paths, and no collect: only one page can keep the containers’ History. Each dot still opens the one container page, which then shows no day for that host’s containers.