Deploy Portainer CE | (Just Updated) Container Management Server, Admin Login And API Locked From Boot

Portainer CE container management server with API, admin login and volume

Deploy Portainer CE | (Just Updated) Container Management Server, Admin Login And API Locked From Boot

/data

Deploy and Host Portainer on Railway

Built for an LLM agent to deploy and use. The deploy form has nothing to fill in: the administrator login is generated and created before the server listens, so no stranger can claim the instance, and Portainer's database, settings and users survive redeploys on a volume. Portainer is an open-source container management UI and HTTP API for Docker, Swarm, Kubernetes and Edge hosts.

About Hosting Portainer

This template runs one service from the upstream Portainer CE image (version 2.45.3, the alpine variant), pinned by digest. Everything Portainer keeps (database, users, settings, certificates) lives on one volume mounted at /data.

No claimable instance. A stock Portainer starts with no administrator, waits for the first visitor to choose a password, and locks itself after five minutes. On a public domain that hands the instance to whoever arrives first, or leaves it stuck on the "timed out" screen. The start command creates the admin user from the generated PORTAINER_ADMIN_PASSWORD before the server listens. On a redeploy Portainer finds the administrator already there and keeps it, so the login is the same every time. There is no self-service sign-up.

What the template fixes for Railway. The web UI and API listen on Railway's injected PORT, which is also the port the healthcheck dials (/api/status, answered without a login). The upstream image has no shell, so the alpine tag is used to let the start command run.

What Portainer manages here. Railway does not give a service a Docker socket, so this Portainer has no local environment and cannot manage Railway itself. It manages your other hosts: add an environment in the UI or the API and connect a Portainer Agent or an Edge Agent running on the Docker, Swarm or Kubernetes host. The Edge tunnel port (8000) is not published, because Railway cannot share one service between an HTTP healthcheck and a TCP proxy.

Using it. Open the service domain, sign in as admin with PORTAINER_ADMIN_PASSWORD (read it from the portainer service variables). For an agent, sign in over the API, mint an access token and send it as X-API-Key as in the contract below.

Agent contract

  • Public URL: PORTAINER_PUBLIC_URL on the portainer service (the generated https address of the service)
  • Private URL: http://portainer.railway.internal:8080
  • Credentials: the variable PORTAINER_ADMIN_PASSWORD on the portainer service (user admin); an API access token is minted from it, there is no fixed API key variable
  • Auth: POST /api/auth with a JSON body holding username admin and password returns a jwt; send it as the header Authorization with the value Bearer plus a space and the token. Mint a long-lived token with POST /api/users/1/tokens (body: password and description) and send the returned rawAPIKey as the header X-API-Key. A request with no key or a wrong one answers 401, so write without key: 401; a wrong login answers 422. Public sign-up is closed: public signup: 401, and the first-visitor admin setup answers 409 because the administrator already exists.
  • Health: GET /api/status returns 200 (no login needed)
#!/bin/sh
# needs: PORTAINER_PUBLIC_URL, PORTAINER_ADMIN_PASSWORD (variables of the portainer service); also curl
R="$PORTAINER_PUBLIC_URL"; J="Content-Type: application/json"
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/api/status")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/api/status"
# log in as admin, then mint an API key (header X-API-Key) for every later call
JWT=$(curl -s -H "$J" -d "{\"username\":\"admin\",\"password\":\"$PORTAINER_ADMIN_PASSWORD\"}" "$R/api/auth" | sed -n 's/.*"jwt":"\([^"]*\)".*/\1/p')
if [ -n "$JWT" ]; then echo "login: ok"; else echo "login: FAILED"; fi
TOK=$(curl -s -H "Authorization: Bearer $JWT" -H "$J" -d "{\"password\":\"$PORTAINER_ADMIN_PASSWORD\",\"description\":\"railway-check\"}" "$R/api/users/1/tokens")
KEY=$(printf %s "$TOK" | sed -n 's/.*"rawAPIKey":"\([^"]*\)".*/\1/p'); KID=$(printf %s "$TOK" | sed -n 's/.*"apiKey":{"id":\([0-9]*\).*/\1/p')
if [ -n "$KEY" ]; then echo "api key: created"; else echo "api key: FAILED"; fi
curl -s -o /dev/null -w "list environments with key: %{http_code}\n" -H "X-API-Key: $KEY" "$R/api/endpoints"
# write with the key: create a tag, read it back, remove it
TAG=$(curl -s -H "X-API-Key: $KEY" -H "$J" -d '{"Name":"railway-check"}' "$R/api/tags" | sed -n 's/.*"ID":\([0-9]*\).*/\1/p')
curl -s -H "X-API-Key: $KEY" "$R/api/tags" | grep -c '"Name":"railway-check"' | sed 's/^/tag found after write: /'
curl -s -o /dev/null -w "delete tag: %{http_code}\n" -X DELETE -H "X-API-Key: $KEY" "$R/api/tags/$TAG"
curl -s -o /dev/null -w "login wrong password: %{http_code}\n" -H "$J" -d '{"username":"admin","password":"wrong-password-0000"}' "$R/api/auth"
curl -s -o /dev/null -w "read without key: %{http_code}\n" "$R/api/endpoints"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -H "$J" -d '{"Name":"anonymous"}' "$R/api/tags"
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -H "X-API-Key: ptr_wrong" -H "$J" -d '{"Name":"anonymous"}' "$R/api/tags"
curl -s -o /dev/null -w "public signup: %{http_code}\n" -H "$J" -d '{"username":"stranger","password":"stranger-password-0000","role":1}' "$R/api/users"
curl -s -o /dev/null -w "first-visitor admin init: %{http_code}\n" -H "$J" -d '{"username":"stranger","password":"stranger-password-0000"}' "$R/api/users/admin/init"
# remove the key this run minted
curl -s -o /dev/null -w "delete api key: %{http_code}\n" -X DELETE -H "Authorization: Bearer $JWT" "$R/api/users/1/tokens/$KID"

A fresh deploy prints health: 200, login: ok, api key: created, list environments with key: 200, tag found after write: 1, delete tag: 204 and delete api key: 204. The refusals print login wrong password: 422, read without key: 401, write without key: 401, write wrong key: 401, public signup: 401 and first-visitor admin init: 409: a request with no key or a wrong one creates nothing, and nobody else can become administrator.

Why Deploy Portainer on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Portainer on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

  • Agent-ready - generated administrator login, a contract block and one script that proves the sign-in, an API access token, a write, a read and a delete with the token, and the refusal of a read and a write with no key or a wrong one.
  • Not claimable - the administrator exists before the first request, so the first visitor gets nothing.
  • Data survives redeploys - users, settings and the database sit on a volume.
  • Always-on control plane - one stable, public address for the hosts you attach.
  • Pinned - the upstream image is pinned by digest.

Common Use Cases

  • One dashboard for remote Docker hosts - attach a home server, a VPS or a Raspberry Pi through an agent and manage its containers, stacks and volumes from one place.
  • Team access to container hosts - give colleagues roles and teams instead of shell access.
  • Edge fleets - manage many small sites with Edge Agents that poll in, with no inbound port opened on the site.
  • Container operations for AI agents - an agent lists, starts and stops containers on attached hosts through the HTTP API.

Dependencies for Portainer Hosting

  • The one portainer service created by the template with its /data volume. Nothing else is required to deploy it; the hosts you manage run their own agent.

Deployment Dependencies


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
52