Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why I can't login SA with docker #315

Open
joelGarcia93 opened this issue May 26, 2018 · 15 comments

Comments

Projects
None yet
9 participants
@joelGarcia93
Copy link

commented May 26, 2018

Hello im trying to install Sql server in Docker to can use it in my Mac. but since 2 days ago I can not fix this error, I've noticed is a popular issue but I don't know how to solve it. someone can help me? before of all Thank you!

MacBook-Air-de-Joel:~ joelgarcia$ docker run --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Jko3va-D9821jhsvGD'. -e 'MSSQL_PID=Enterprise' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest d4848181f0a171f0b1b29cc59489961432894016c3ac9f0304d180a66c7343e6 MacBook-Air-de-Joel:~ joelgarcia$ mssql -s localhost -u sa -p Jko3va-D9821jhsvGD Connecting to localhost... Error: Login failed for user 'sa'.

I also tried with this

MacBook-Air-de-Joel:~ joelgarcia$ sudo docker exec -it sql_server_demo /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Jko3va-D9821jhsvGD Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'sa'..

@twright-msft

This comment has been minimized.

Copy link
Collaborator

commented May 27, 2018

Have you tried a different password? Try something relatively simplistic like Banana100
Also when connecting on a macbook try using 127.0.0.1 instead of localhost.

@joelGarcia93

This comment has been minimized.

Copy link
Author

commented May 27, 2018

it doesn't work, I've changed more than 30 times the password.

MacBook-Air-de-Joel:~ joelgarcia$ docker run --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Banana100'. -e 'MSSQL_PID=Enterprise' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest a0a1a0fe5e3946f36f747a24f43bb8f6372529391b9a153b799eb699f27480a0

MacBook-Air-de-Joel:~ joelgarcia$ mssql -s 127.0.0.1 -u sa -p Banana100 Connecting to 127.0.0.1... Error: Login failed for user 'sa'.

MacBook-Air-de-Joel:~ joelgarcia$ sudo docker exec -it sql_server_demo /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P Banana100 Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'sa'..

@brentarias

This comment has been minimized.

Copy link

commented May 29, 2018

I have the same problem. On my Windows 10 Pro (v 1803) I created my container from a powershell prompt:

docker run -d -p 1433:1433 --name sql1 -e sa_password=SecurePassword -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer:2017-latest

Afterward, the following command works:

docker exec -it sql1 sqlcmd -S localhost

The above gives me access as "User Manager\ContainerAdministrator". However, the following command fails with "Login failed for user 'sa'":

docker exec -it sql1 sqlcmd -S localhost -U sa -P SecurePassword

I tried omitting the "-P SecurePassord" portion, so that it would interactively request the password. When I enter the password interactively, it still does not work. I have also tried a "docker rm" of the container, to start fresh. The second time around with "docker run" I put the password in quotes -e "sa_password=SecurePassword". Still didn't work.

Incidentally, I have yet to find any MS documentation online that explains the "ContainerAdministrator" account and why it requires no password. Elsewhere I read that the 'sa' account is disabled by default for SQL Server. Perhaps that is the problem in this Docker context? I've not yet seen any documentation online, from any source, that explains how to enable the 'sa' account in a Docker container.

Here is my "docker info":

Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 1
Server Version: 18.03.1-ce
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 16299 (16299.431.amd64fre.rs3_release_svc_escrow.180502-1908)
Operating System: Windows 10 Pro
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 15.84GiB
Name: PHXL1000009
ID: TYSY:KAL5:IJHZ:HKIE:KL57:RXGU:C5YC:2JRK:P4V7:2E3M:TBTC:6FYX
Docker Root Dir: C:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: -1
Goroutines: 35
System Time: 2018-05-29T13:45:12.4098754-07:00
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

@brentarias

This comment has been minimized.

Copy link

commented May 29, 2018

I think I found the problem for both myself and @joelGarcia93

Password Complexity

In my case, the password "SecurePassword" does not pass complexity validation. Instead of receiving an error, the container starts without any sign of an error. However, I can then no longer login as SA. I stopped and removed my container, then re-created it with "docker run" but this time I changed the password to "1Secure*Password1". Now having a complexity-valid password, finally I am able to log in as SA.

Environment Variable Name

In Joel's case, I believe he is using an incorrectly named environment variable. Instead of:

-e 'MSSQL_SA_PASSWORD=Jko3va-D9821jhsvGD'

I believe it should be:

-e 'SA_PASSWORD=Jko3va-D9821jhsvGD'

Conclusion

If the the SA password is not specified, or if it does not pass a complexity test - the "docker run" command will not provide any indication that there is a problem. Perhaps this is where the real problem is?

Cheers!

@joelGarcia93

This comment has been minimized.

Copy link
Author

commented May 30, 2018

at least for me, It doesn't work yet :(! I changed the Password as @brentarias said and also I changed SA_PASSWORD instead MSSQL_SA_PASSWORD.

MacBook-Air-de-Joel:~ joelgarcia$ docker run --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=1Secure*Password1'. -e 'MSSQL_PID=Enterprise' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest 3c970aad439fc3ea765203f151bca77bb56ff1d49ab167c3301af7dd27c7a7f7

MacBook-Air-de-Joel:~ joelgarcia$ mssql -s localhost -u sa -p 1Secure*Password1 Connecting to localhost... Error: Login failed for user 'sa'.

MacBook-Air-de-Joel:~ joelgarcia$ docker exec -it sql_server_demo opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 1Secure*Password1 Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'sa'..

some advice? thanks

@twright-msft

This comment has been minimized.

Copy link
Collaborator

commented May 30, 2018

@joelGarcia93 - I tried your exact commands via copy/paste and got the same error on my macbook. I tried various combinations of things and ultimately got it to work by removing the MSSQL_PID env var. Ah hah! I thought I must have found a bug, but when I added it back to be sure, it still worked with the MSSQL_PID env var. Then I noticed what I think is the actual problem you are having. There is a sneaky little period after your password environment variable that is for some reason throwing everything off.

Your original command:

docker run --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=1Secure*Password1'. -e 'MSSQL_PID=Enterprise' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest

Should be:

docker run --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=1Secure*Password1' -e 'MSSQL_PID=Enterprise' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest

Output on my mac:

$ docker run --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=1Secure*Password1' -e 'MSSQL_PID=Enterprise' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest
a340c909afafad73571029674603b973fefab5a141780ee9cc02ed11557d5bb4
$ docker ps
CONTAINER ID        IMAGE                                      COMMAND                  CREATED             STATUS              PORTS                    NAMES
a340c909afaf        microsoft/mssql-server-linux:2017-latest   "/bin/sh -c /opt/mss…"   19 seconds ago      Up 1 second         0.0.0.0:1433->1433/tcp   sql_server_demo
$ docker exec -it sql_server_demo /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 1Secure*Password1
1> 

Please confirm and hopefully we can close this one out! :)

@joelGarcia93

This comment has been minimized.

Copy link
Author

commented May 30, 2018

@twright-msft Thank you so much, now it works like a charm!! Im gonna continue working with .Net Mvc Framework with Sql server.

You are very kind, Thank you so much!!

@rnmulchandani

This comment has been minimized.

Copy link

commented Sep 4, 2018

@twright-msft
Hi, I tried to run the same command but it failed for me.

C:\Users\mulchr>docker run --name sql1 -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=1Secure*Password1' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest
312fd83bc65cc8eaa432355c70f0bf4061cd38045c075f3c747cd9d6acaaa561

C:\Users\mulchr>docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 1Secure*Password1
Error response from daemon: Container 312fd83bc65cc8eaa432355c70f0bf4061cd38045c075f3c747cd9d6acaaa561 is not running

C:\Users\mulchr>docker ps -a
CONTAINER ID        IMAGE                                      COMMAND                  CREATED             STATUS                      PORTS               NAMES
312fd83bc65c        microsoft/mssql-server-linux:2017-latest   "/opt/mssql/bin/sq..."   21 seconds ago      Exited (1) 12 seconds ago                       sql1

Could you please help me in this? I don't know why the container exits immediately.

@twright-msft

This comment has been minimized.

Copy link
Collaborator

commented Sep 5, 2018

Couple of things to try -

  1. A different password - no symbols, just uc/lc letters and numbers
  2. run docker logs sql1
@OndeVai

This comment has been minimized.

Copy link

commented Nov 8, 2018

In my case I was running into the same thing but just with docker-compose. Turns out the the environment vars need to be quoted to handle special chars. Newbie mistake :)

mssql: image: mcr.microsoft.com/mssql/server:latest ports: - "1433:1433" environment: - "ACCEPT_EULA=Y" - "SA_PASSWORD=P@ssword66" - "MSSQL_PID=Express" networks: - aspnetcore-network

@mcjiffy

This comment has been minimized.

Copy link

commented Nov 8, 2018

I met this issue too. And I soled it.
Juse saw the logs:

docker logs mssql
ERROR: Unable to set system administrator password: Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols..

To change a password and use SQL Server password policy.It works.

@hiteshbhandari

This comment has been minimized.

Copy link

commented Feb 7, 2019

container

Thanks for the suggestion. Worked in my case regarding password complexity part

@vpaulino

This comment has been minimized.

Copy link

commented Mar 13, 2019

Hi there

I'm having issues with my SA user and password that I created. according to the rules, the password should be valid. Here is a printscreen regarding what I have done in powershell:

image

Any ideias ?

@vpaulino

This comment has been minimized.

Copy link

commented Mar 13, 2019

I found it.

looks like it the " cannot be used to represent the password string. it should be used the ' !

@blackat

This comment has been minimized.

Copy link

commented Apr 22, 2019

Under Windows
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Manager2017" -e "MSSQL_PID=Enterprise" -p 1433:1433 --name mssql -d mcr.microsoft.com/mssql/server:2017-latest
pay attention to doube " for the password, the single ' does not work when I login.

Under Mac no issue with single '.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.