mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-07-29 00:32:35 -04:00
Refine password validation to separately check length and character requirements for better clarity. Add detailed error messages showing password length and value on failure. Implement automatic Portainer restart attempts on validation failure to maintain service availability.
Reset Portainer Password
This script helps you easily reset the administrator password for your Portainer instance using the official Portainer helper-reset-password container.
Features
- Automatic Detection: Automatically finds your Portainer container and data volume
- Multiple Deployment Support: Works with containers, services, and stacks
- Safe Operation: Properly stops and restarts Portainer during the reset process
- Clear Output: Displays the new password clearly for easy copying
- Error Handling: Comprehensive error checking and recovery
Prerequisites
- Docker must be installed and running
- Portainer must be installed with a persistent data volume
- Root or sudo access may be required
Usage
Run the script directly from GitHub:
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/reset-portainer-password/run.sh)"
Or with curl:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/reset-portainer-password/run.sh)"
What the Script Does
- Checks Docker Status: Verifies Docker is running and accessible
- Finds Portainer: Automatically locates your Portainer container
- Detects Data Volume: Identifies the Portainer data volume
- Determines Deployment Type: Detects if running as container, service, or stack
- Stops Portainer: Safely stops the Portainer instance
- Resets Password: Uses the official Portainer helper to reset the admin password
- Restarts Portainer: Brings Portainer back online
- Displays New Password: Shows the new randomly generated password
Supported Deployments
- Standard Container:
docker rundeployments - Docker Services:
docker servicedeployments - Docker Stacks: Stack-based deployments
Important Notes
- ⚠️ This will temporarily stop your Portainer instance during the reset process
- 🔐 Save the new password immediately - it's randomly generated and cannot be recovered
- 👤 Resets the original admin account (UserID == 1) - if removed, creates a new admin user
- 📝 Works with persistent storage - both named Docker volumes and bind mounts are supported
Troubleshooting
Container Not Found
If the script can't find your Portainer container, ensure:
- Portainer is installed and the container exists
- The container name contains "portainer"
Volume or Bind Mount Not Found
If the data storage can't be located:
- Verify Portainer has persistent storage mounted to
/data(either a named volume or bind mount) - For named volumes: Check that the volume exists with
docker volume ls - For bind mounts: Ensure the host directory exists and is accessible
Permission Errors
If you encounter permission errors:
- Run the script with
sudo - Ensure your user is in the
dockergroup
Security
This script uses the official Portainer helper container (portainer/helper-reset-password) which:
- Only resets the password for the original administrator account
- Generates a secure random password
- Does not expose or store credentials
Support
If you find this script helpful, please consider supporting BigBearTechWorld:
Related Scripts
- Update Portainer CE - Update your Portainer installation
- Install Docker - Install Docker on your system