Environments and endpoints
A Portainer with no environment manages nothing; it is a console admiring itself. This chapter gives it an engine to look after — the local one first, through its socket — and explains the other three ways an engine can be attached, so you can tell which of your machines wants which. By the end, the environment list shows one engine, up, and you have asked it its version through Portainer and got the engine's own answer.
Check: transcript
portainer-lab/transcripts/t03-endpoints.txt
— the empty list, the creation, and
"Server version (via Portainer
proxy): 4.9.3", which is Podman's
version, reported by Podman.
The local engine
In the web interface: Environments →
Add environment → Docker, and choose
the socket. Portainer proposes the
standard path, /var/run/docker.sock,
which is the very socket it was itself
handed in chapter 3 — it can see the
engine it lives beside. Give it a name
you will recognise in a list (local
is the honest classic), and save.
The lab did the same thing through the API, because the lab verifies what it can script (transcript t03):
curl -X POST http://localhost:9000/api/endpoints \
-H "Authorization: Bearer <jwt>" \
-F "Name=local" -F "EndpointCreationType=1" \
-F "URL=unix:///var/run/docker.sock"
EndpointCreationType=1 is "a Docker
environment, here, by socket". The
record that comes back — and that the
environment list then shows — carries
Status: 1, Portainer's "up": it
asked the engine, and the engine
answered. An environment is up or
down in exactly this sense, a
fresh answer each time Portainer
takes a snapshot of the
environment for its home page.
One subtlety the lab earned: a fresh
Portainer does not create this
environment by itself, socket or no
socket. The lab's first list was
empty ([]), and yours will be too.
Registering the engine is a deliberate
act, done once, by the administrator.
Engines that are not Podman-shaped
The lab's engine is Podman answering on a Docker-compatible socket, and Portainer neither knows nor cares — the API is the contract, and anything that honours it is an engine. A real Docker daemon is, of course, the ordinary case, and everything in this guide was written to hold for it unchanged.
The other three doors
- By network address. An engine can expose its API over TCP. Attach by address and port, and turn on TLS with certificates, so the API's traffic — which is root-shaped traffic (chapter 14) — is not crossing the network in the clear with only optimism for armour. Fine inside a trusted network; think twice beyond it.
- By agent. The Portainer Agent is a small container you run on the other machine, beside its engine. Portainer talks to the agent; the agent talks to the local socket. This is the usual way to manage a second and third machine: no engine API exposed, one purpose-built door, secured with a shared secret set at install.
- By Edge agent. Some machines Portainer cannot reach at all — they sit behind other people's networks. An Edge agent inverts the arrangement: it polls Portainer over the tunnel port (chapter 3's 8000) and takes its instructions home with it. Slower to respond, and the only thing that works out there.
Kubernetes clusters attach as environments too, with their own pages; that is a larger country, and this guide points at its border (chapters 13 and 14) rather than pretending a section is a visit.
Groups, tags, and tidiness
With several environments, Portainer lets you file them into groups and stick tags on them, which matter later for access (chapter 11 grants access per environment) and for your own sanity at nine machines. With one environment, skip it all — but name that one thing honestly, because every later chapter, picker and permission will call it by the name you choose.