ultrajohn
ultrajohn

Reputation: 2597

Resetting admin password of Metabase in Docker Desktop Windows 11

Good day.

How do I reset the admin password of Metabase that is installed using Docker Desktop on Windows 11?

Thanks.

Upvotes: 1

Views: 3367

Answers (4)

StonedCodingTom
StonedCodingTom

Reputation: 151

For anyone looking for docker in a terminal way: (I'm using docker network between images)

docker run --rm -it \
  --network my_network \
  -e MB_DB_TYPE=postgres \
  -e MB_DB_DBNAME=your_db_name \
  -e MB_DB_HOST=db_image_name \
  -e MB_DB_PORT=5432 \
  -e MB_DB_USER=your_user \
  -e MB_DB_PASS=your_password \
  --entrypoint="" \
  metabase/metabase \
  java -jar /app/metabase.jar reset-password [email protected]

You get token in the terminal, copy it and you can now start docker image in the normal way like: docker start image_name

Now enter token in the url for password reset: http://localhost:3000/auth/resetpassword/token

Upvotes: 0

OrangePot
OrangePot

Reputation: 1082

For kubernetes manifests the action can be done like so:

      ...
      containers:
        - name: metabase
          image: metabase/metabase:v0.50.6
          args: ["reset-password [email protected]"]
      ...

Upvotes: 0

Sander Voss
Sander Voss

Reputation: 33

In your docker run, add the command "reset-password [email protected]" where you use the admin account email. The logs will then provide a token which you can use to reset the password.

The docker container will exit after providing the token so you will have to restart the container (without the reset password command).

Reset the password by going to http://<ip>:<port>/auth/reset_password/<token>.

Explanation:

The docker entrypoint is ENTRYPOINT ["/app/run_metabase.sh"] which handles launching the application. The last part of that file states

# Launch the application
    # exec is here twice on purpose to  ensure that metabase runs as PID 1 (the init process)
    # and thus receives signals sent to the container. This allows it to shutdown cleanly on exit
    exec su metabase -s /bin/sh -c "exec java $JAVA_OPTS -jar /app/metabase.jar $@"

This $@ means it will append any additional arguments that you provided to it. So there is no need to edit any files or go into a running docker container to stop and start something with a specific command. You can simply add the required command (as per https://www.metabase.com/docs/latest/people-and-groups/managing#resetting-the-admin-password) to the docker run command (or docker compose if you are using that).

Upvotes: 0

ultrajohn
ultrajohn

Reputation: 2597

Part of the answer can be found here. The guide says,

If you’re a Metabase admin and have access to the server console, you can get Metabase to send you a password reset token:

Stop the running Metabase application. Restart Metabase with reset-password [email protected], where “[email protected]” is the email associated with the admin account: java -jar metabase.jar reset-password [email protected]

MODIFYING THE FILE

On Docker Desktop, what you need to do is to modify run_metabase.sh and add the reset-password flag as described above.

  1. On Docker Desktop, this is easy. In Containers, look for Metabase. Under action, click on the 3-dotted button, and select View Files. Under app folder, select run_metabase.sh to open the file.
  2. Add the reset-password flag with the admin email as described above. In my case, I modified line 172. Save the file.

enter image description here

At this point, you can now restart and continue following the guide above. However, if you were like me, you will encounter a permission denied error and Metabase won't start successfully as before. Modifying and saving the file in the Docker Desktop editor removed the execute flag of the file.

FIXING THE Permission Denied Error

To reset the file's permission, open a terminal in the WSL guest you are using.

  1. Navigate to /mnt/wsl/docker-desktop-data/version-pack-data.
  2. Perform a search of the run_metabase.sh file using find . -name run_metabase.sh. This will give you the location of the file.
  3. Using that location, modify the permission of the file using chmod +x path/to/run_metabase.sh.
  4. On Docker Desktop, try to run the Metabase again. It should work now. Copy the reset-password token provided in the terminal logs.

At this point, you need to revert the changes you've made in the run_metabase.sh file, reset the permission as described above, then restart Metabase again. You can now access the reset-password link and use the token obtained previously to reset the password of your Metabase admin account.

I hope this helps.

Upvotes: 0

Related Questions