In our case we are trying to reset admin password on the Jenkins instance, that is running on Docker container.
1. Basically there is no need in stopping container. But just in case:
docker container stop jenkins
"jenkins" here is the name of our container.
2. Since we have mounted volume for storing jenkins data, named "jenkins_data" let's check it's location on the server:
docker volume inspect jenkins_data
Output will obviously show us jenkins volume folder. In our case it is: /var/lib/docker/volumes/jenkins/_data
3. Rise server access role to root by typing "sudo su" in command line and then cd to obtained location.
4. Make a copy of jenkins config file:
cp config.xml config.xml.bak
5. Open config.xml with your most liked text editor, mine still is vim. And disable any security on jenkins by changing <useSecurity> to false:
<useSecurity>false</useSecurity>
6. Start docker container:
docker container start jenkins
7. After Jenkins up and running, it will give you unrestricted access to dashboard. Navigate to "Manage Jenkins" and then to the "Security" page inside Security section. In Authentication block choose "Jenkins own user database" in the "Security Realm" dropdown. Click SAVE.
8. When saved, you will notice new page available inside Security section, which will be spelled "Users". Click on it.
9. Navigate to your users page and reset password by typing new one and confirming it. Save the changes.
10. Restore original Jenkins config:
mv config.xml.bak config.xml
11. And restart again jenkins container:
docker container restart jenkins
Done. You will now be able to log into your Jenkins instance, running on Docker container.