Skip to main content

Sitecore

How to Reset the Sitecore Admin Password inside a Docker Container

Lock on a Keyboard

I’ve experienced an issue setting up the Lighthouse Demo and the Play Summit demo in recent weeks. Once I get through all the normal issues of setting up a new environment, I can’t log into Sitecore. I know I passed “b” to the init script, but alas, I get an invalid username and password error.

I’ve gotten around it by resetting the password in the database. Since the database is running in containers, This isn’t as straight forward as it seems. Connecting to your SQL instance in containers is covered well by Neil Killan on his blog post on “Querying your Sitecore SQL Container“, but for convenience you need to run the following command, specifying the id of your sql container.

>docker inspect container [containerID]

Where container id is the id for your container. You can easily copy the ID right from docker desktop by clicking the copy icon next to the ID.

Docker Desktop

Once you run that you will find the IP in the network section

Docker Inspect Container Result

Copy that, and then look up the SQL sa password in the env file in the root of your solution.

Env File

That will allow you to login using the “sa” account into SQL Management studio.

Sql Login

Once there, you can reset the password on the admin account by running a query in the core database. After googling for that query, you’ll most likely end up on this stack overflow article.  

I think the higher ranked answers are for older versions of sitecore, but I found the answer by Dan Sinclair works for the Sitecore 10 instances these demo sites use.  For convenience here is the query:

UPDATE[aspnet_Membership] 
SET[Password]='K8N8GUW8UiNT2mPdjvuBDH+QmvA3R61M9buVvCwFHwtDjpMzTxs34lg0uQ0azCITqh6FkUZlX4kM72lsAyuyXQ==', 
    [PasswordSalt]='p5B6HOWKt0ctMZaSNXTlfw==', 
    [IsApproved] ='1', 
    [IsLockedOut] ='0'WHEREUserId IN(
        SELECTUserId FROMdbo.aspnet_Users WHEREUserName ='sitecore\admin');

After running that, the account should be good to login with good old password “b”

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

David San Filippo, Principal

David is the Prinicpal of the Sitecore and Optimizely practice at Perficient, David estimates, architects and delivers digital marketing solutions at scale on the Sitecore Platform. A 4X Sitecore Technology MVP, David has written articles for MSDN Magazine and the Microsoft Architecture Journal. He has spoken at Sitecore Symposium, Sitecore Virtual Developer Day, user group meetings and code camps.

More from this Author

Categories
Follow Us