TechieHints SOFTWARE

How to reset Jenkins password in the docker environment ?

Here’s a comprehensive guide on how to reset your Jenkins password when it’s running inside a Docker container. I’ve combined the best aspects of previous responses and addressed potential issues:

Methods:

1. Modifying the config.xml File:

  • Find your Jenkins volume:
    • If you used the official Jenkins image, the volume is likely at /var/jenkins_home. You can verify this by inspecting your Docker container.
  • Access the container:
    • Use docker exec -it <container_name> /bin/bash to enter the container’s shell.
  • Temporarily disable security:
    • Open /var/jenkins_home/config.xml in a text editor.
    • Find the <useSecurity> tag and change its value to false.
    • Save the changes.
  • Restart Jenkins:
    • Exit the container shell.
    • Depending on your setup, you might need to restart the container using docker restart <container_name>.
  • Reset password via Jenkins UI:
    • Access Jenkins in your browser; you shouldn’t need to log in.
    • Go to Manage Jenkins -> Configure Global Security.expand_more
    • Enable Jenkins’ own user database.expand_more
    • Go to People, click on ‘admin’, and set a new password.
  • Re-enable security:
    • Edit /var/jenkins_home/config.xml again.
    • Change the <useSecurity> tag back to true.
    • Save the changes and restart your Jenkins container (if you didn’t already).