Yes, absolutely. Portainer's service definitely requires persistent storage.
Here's why:
Storing Critical Data: Portainer isn't just a stateless web interface. It stores:
User Accounts & Permissions: All your users, teams, and their access rights.
Endpoint Configurations: Details about the Docker Swarm, standalone Docker hosts, or Kubernetes clusters it manages.
Application Stacks/Services: Definitions of the applications you deploy and manage through Portainer.
Settings and Configurations: Portainer's internal settings, API keys, etc.
What Happens Without Persistence?
If Portainer's data is lost (e.g., if its container restarts or gets rescheduled to a different node without access to its previous data), you will:
Lose all your user accounts and permissions.
Lose all configurations for your Docker endpoints, meaning you'd have to re-add all your managed environments.
Lose the list of all stacks and services that were deployed and managed by Portainer. The underlying services would still be running in Swarm, but Portainer wouldn't know about them or be able to manage them.
Essentially, Portainer would be reset to its factory default state, requiring a full re-setup.
How is it Implemented in Swarm?
As shown in the setup instructions, Portainer is deployed with a volume mount:
--mount type=volume,src=portainer_data,dst=/data
This portainer_data is a Docker named volume.
The Swarm Consideration:
While Portainer Server is typically run as a single replica (--replicas=1) in a Swarm, the Swarm orchestrator can reschedule that single task to any available node. For Portainer to remain functional and retain its data, the portainer_data volume must be accessible from any node where the Portainer task might run.
This means the storage backing that named volume needs to be shared or accessible across all nodes in your swarm. This is why solutions like NFS, GlusterFS, Ceph, or specific Docker Volume Plugins/Drivers that provide distributed or shared storage are crucial for a resilient Portainer deployment in Docker Swarm.
In summary: Yes, persistent storage is mandatory for Portainer to function correctly and retain its management state. For a robust Docker Swarm deployment, this persistence typically needs to be provided by a shared storage solution.