Skip to content

Installing Portainer

Portainer is installed the way the things it manages are installed: as a container, from an image, with one volume for its memory. By the end of this chapter it is running and answering, and — just as important — you know the two commands that prove it, so chapter 4's first login starts from solid ground.

Check: curl http://localhost:9000/api/system/status prints the version. The lab's answer (transcript portainer-lab/transcripts/t01-install.txt) reads {"Version": "2.45.3", ...}.

Before you start

You need one machine with a container engine already working — Docker, most often. Portainer does not bring an engine with it; if docker ps fails, fix that first, because no console can manage an engine that is not there. You also need the engine's socket path, which is the install's one real input:

  • Docker, on Linux: /var/run/docker.sock
  • Podman, offering its compatible socket: often /run/podman/podman.sock (the lab used its own scratch socket; transcript t90 tells that story)

The install

Two steps: a volume for the memory, then the container itself.

docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 \
  --name portainer --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:latest

(The lab ran the same shape against its Podman socket — transcript t01 shows its pull, its ps line, and its status answer.) Read the flags once, properly:

Part What it does
-v /var/run/docker.sock:/var/run/docker.sock Hands Portainer the engine's front door — the whole point, and the whole privilege (chapter 1's rule)
-v portainer_data:/data Its memory, in a named volume that survives the container (chapter 2)
-p 9443:9443 The web interface over HTTPS, with a certificate Portainer makes itself
-p 9000:9000 The same interface over plain HTTP — add it if you want it; the guide's lab used it on a loopback-only machine
-p 8000:8000 A tunnel port used only by Edge agents; harmless to publish, pointless without them
--restart=always The console comes back when the machine does

The self-signed certificate on 9443 will make your browser warn you, once, in strong language. That warning is the browser doing its job: the certificate is real encryption with an unverifiable name tag. On your own network this is the normal Portainer experience; chapter 14 talks about when it is not enough.

Why the socket line deserves a pause

/var/run/docker.sock is not a monitoring tap. Whoever can write to it can start any container with any host folder mounted — which is to say, can do anything on the machine. Mounting it into Portainer is necessary, and it is exactly why chapter 1's rule exists and why chapter 4's first login is guarded. Install cheerfully; just know what you installed.

Knowing it worked

docker ps                 # portainer, Up
curl http://localhost:9000/api/system/status

The status answer carries the version and an instance id, and needs no login: it is the one thing a fresh Portainer tells strangers, along with the setup screen itself. Now go straight to chapter 4. A fresh console is an unclaimed privileged door, and the next chapter closes it properly.