'How to reset Jenkins Admin account password? I am running Jenkins in Docker in windows

I have created an Admin account in Jenkins after unlocking the Jenkins and doing the initial setup. Now I have forgot the password of the admin account and I am not able to login Jenkins



Solution 1:[1]

As you running Jenkins in a Docker container you have to go to the inside of the container.

by typing below command $docker exec -it (container-ID) /bin/bash

After entering the container you should follow these step which mentioned on this post https://techpostal.blogspot.com/2020/01/how-to-reset-jenkins-admin-password.html

then check it and one more thing when you are done with the resetting password you shoud commit the docker images for future use of that image.

Solution 2:[2]

First, enter the docker container by using

sudo docker exec -it [containerID] bin/bash

Your container is likely clean and need to install editing tools, run

apt-get update && apt-get install nano

Then, find the config.xml file. For my container, it is in /var/jenkins_home/config.xml. You can also try /var/lib/jenkins/config.xml.

nano /var/jenkins_home/config.xml

Terminal Screen Cap Change the useSecurity tag to false.

docker restart [ContainerID]

Now, you can visit the Jenkins page and it should be showing the Dashboard right the way without password. You should reset the password, by going to Dashboard -> Manage Jenkins -> Security -> Configure Global Security , set Security Realms to Jenkins' own user database and press Apply.

Next, go to People and click the admin account, you should be redirected and see a button named Configure, set a new set of password in Password section and press Apply.

Then, go to Configure Global Security again, set Authentication to the option other than Anyone can do anything

Your password should have been reset, finally, go set the value of useSecurity to true again and restart the container. Hope this help!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ramya ranjan
Solution 2