I have this docker-compose.yml
version: '3'
services:
mssql-server-linux:
image: microsoft/mssql-server-linux:latest
volumes:
- mssql-server-linux-data:/var/opt/mssql/data
environment:
sa_password: "P@ssW0rd"
ACCEPT_EULA: "Y"
ports:
- "14331:1433"
volumes:
mssql-server-linux-data:
After executing docker-compose up, everithing seems ok but i can麓t login. it always throws me this error:
2018-03-22 22:58:59.97 Logon Login failed for user 'sa'. Reason: Password did not match that for the login provided. [CLIENT: 172.18.0.1]
Any idea?
It seems that when you modify the docker-compose.yml changing the password after the first successful run, the password does not change. the only way i have to make this work again is to move the .yml file to another folder and re-run docker-compose up again...
This happens because the password is stored in the master database. Because you persisted the master database files using the volume mount, the password is already stored there. If you re-run another container and mount to the same location the new container will just use the existing master DB and the password inside of it and ignore the new password you specified. If you want to use a new password with the original master DB then you need to log in using the old password and change it to a new password. If you want a new container and new master DB with a new password then you need to stop the container, delete the database files on the host, and then start a new container with the new password.
Thank you Travis, that make sense.
@twright-msft here's an example of where I don't persist my containers
version: '3.5'
networks:
test:
driver: bridge
azure_db:
container_name: azure_db
image: microsoft/mssql-server-linux:2017-CU5
networks:
- test
ports:
- "1433:1433"
environment:
ACCEPT_EULA: Y
SA_PASSWORD: "azure_PASSWORD,123"
The SQL Server container gives me
Login failed for user 'sa'. Reason: Password did not match that for the login provided. [CLIENT: 172.21.0.1]
when attempting to log on with username "SA" and password "azure_PASSWORD,123".
Any ideas how to resolve this please?
Interesting. Maybe try without the special characters - underscore and comma?
Thank you for your response. I re-tried with azurePASSWORD123 as password and get the same response from the database server.
Update: I believe I had attempted logging in with username 'SA' instead of the correct lowercase 'sa'. So likely just my fault here.
I ran into this issue and for me it was a password that included the @ character. Thank you!
On docker page the example is:
db:
image: "microsoft/mssql-server-linux"
environment:
SA_PASSWORD: "Your_password123"
ACCEPT_EULA: "Y"
I use '=' instead of ':' but the setting takes all chars after = (notice the space after SA_PASSWORD:)
In my case it should be: SA_PASSWORD=Your_password123
Note: the image is also changed from the one in the example to:
mcr.microsoft.com/mssql/server:latest
Be aware that if you use the $ in your password you need to escape it via $$ (i.e. "My_pass$$" has to written as "My_pass$$$$")
Most helpful comment
This happens because the password is stored in the master database. Because you persisted the master database files using the volume mount, the password is already stored there. If you re-run another container and mount to the same location the new container will just use the existing master DB and the password inside of it and ignore the new password you specified. If you want to use a new password with the original master DB then you need to log in using the old password and change it to a new password. If you want a new container and new master DB with a new password then you need to stop the container, delete the database files on the host, and then start a new container with the new password.