[Portainer] Reset admin user password (container)

If the Portainer admin password is lost, follow these steps to reset it. There are three methods depending on your Portainer environment.

Here the first solution is discussed

Method 1: Resetting the admin password if Portainer runs as a container.

root@ubuntu18:~# docker ps | grep portainer
CONTAINER ID   IMAGE                                 COMMAND                  CREATED          STATUS          PORTS                                                           NAMES
c57fe60fe013   portainer/portainer-ce                "/portainer"             2 days ago       Up 4 hours      8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp   Portainer

root@ubuntu18:~# docker stop c57fe60fe013
c57fe60fe013

root@ubuntu18:~# docker pull portainer/helper-reset-password
Using default tag: latest
latest: Pulling from portainer/helper-reset-password
02b4906c8588: Pull complete
ddb28a3a02c2: Pull complete
Digest: sha256:327a5580faf6a67e1eb98f4fac41bab14af7425ea88437b680945c995f1529e9
Status: Downloaded newer image for portainer/helper-reset-password:latest
docker.io/portainer/helper-reset-password:latest

root@ubuntu18:~# docker run --rm -v portainer_data:/data portainer/helper-reset-password
{"level":"info","filename":"portainer.db","time":"2024-08-23T19:40:52Z","message":"loading PortainerDB"}
2024/08/23 19:40:53 Password successfully updated for user: admin
2024/08/23 19:40:53 Use the following password to login: @k5Ab&En4&&@Lm=1[oQ.  (already expired , just for presentation purpose)

root@ubuntu18:~# docker start c57fe60fe013

c57fe60fe013
root@ubuntu18:~#


root@ubuntu18:~# docker ps | grep portainer

CONTAINER ID   IMAGE                                 COMMAND                  CREATED          STATUS          PORTS                                                           NAMES

c57fe60fe013   portainer/portainer-ce                "/portainer"             2 days ago       Up 36 minutes   8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp   Portainer

Link: https://docs.portainer.io/advanced/reset-admin