I'm trying to setup SQLserver on my mac using Docker.
When I start it, it seems to be working, but when I try to connect with mssql, it crashes.
I have tried with localhost instead of 0.0.0.0, same result.
iMac benoitd$ **docker run** -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=DB22017' -p
1433:1433 -d microsoft/mssql-server-linux
ee2f1a94410dfb6e5f39ba009ffee20b906270e9602d831ff2344e93d2ec5d14
iMac benoitd$ **docker ps**
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ee2f1a94410d microsoft/mssql-server-linux "/bin/sh -c /opt/mssq" 4 seconds ago Up 2 seconds 0.0.0.0:1433->1433/tcp awesome_mahavira
iMac benoitd$ **mssql -s 0.0.0.0:1433 -u sa -p 'DB22017'**
Connecting to 0.0.0.0:1433...
Error: Failed to connect to 0.0.0.0:1433:1433 - getaddrinfo ENOTFOUND 0.0.0.0:1433 0.0.0.0:1433:1433
iMac benoitd$ **docker ps**
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d'oh.... the problem was with the password for sql server. It need to be a strong pw.
thanks for your help! and happy new year :)
Related
Cannot connect to mssql localhost instance via Azure Data Studio. Get: 'login failed for user sa'.
In the same time I'm able to successfully connect via terminal: mssql -u sa -p myPassword
mssql is in docker with status up
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=myPassword" -p 1433:1433 --name sql1 -h sql1 -d mcr.microsoft.com/mssql/server:2019-latest
os: ubuntu 20.04
firewal is off
I'm sure that pwd is correct, as I can connect to mssql via terminal. Is it Azure settings? Or ubuntu?
Thank you in advance!
I was able to connect to sql instance via Azure Data Studio after change the password. I was using special characters (#, #, $) that might have caused the problem.
After altering password that doesnt iclude special characters it starts working!
I'm trying to setup MSSQL at Docker at Windows 10, but for some reason it started shutting down my container
I've been using it like that for months, but now I have no idea what's happening
C:\Users\user\
λ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
C:\Users\user\
λ docker login
Authenticating with existing credentials...
Login Succeeded
C:\Users\user\
λ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>123' -p 1433:1433 --name sql -d mcr.microsoft.com/mssql/server:2017-latest
337e5efb35f0bf4b465181a0f8be4851b12f353a3a8710ddf817d2f501e5fea
C:\Users\user\
λ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
347q5effb3cf0 mcr.microsoft.com/mssql/server:2017-latest "/opt/mssql/bin/sqls…" 3 seconds ago Up 2 seconds 0.0.0.0:1433->1433/tcp sql
C:\Users\user\
λ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
347q5effb3cf0 mcr.microsoft.com/mssql/server:2017-latest "/opt/mssql/bin/sqls…" 6 seconds ago Exited (1) 2 seconds ago sql
C:\Users\user\
λ docker start sql
sql
C:\Users\user\
λ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
347q5effb3cf0 mcr.microsoft.com/mssql/server:2017-latest "/opt/mssql/bin/sqls…" 14 seconds ago Up 2 seconds 0.0.0.0:1433->1433/tcp sql
C:\Users\user\
λ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
347q5effb3cf0 mcr.microsoft.com/mssql/server:2017-latest "/opt/mssql/bin/sqls…" 16 seconds ago Exited (1) 1 second ago sql
docker logs sql
shows
The SQL Server End-User License Agreement (EULA) must be accepted before SQL
Server can start. The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388.
You can accept the EULA by specifying the --accept-eula command line option,
setting the ACCEPT_EULA environment variable, or using the mssql-conf tool.
The SQL Server End-User License Agreement (EULA) must be accepted before SQL
Server can start. The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388.
You can accept the EULA by specifying the --accept-eula command line option,
setting the ACCEPT_EULA environment variable, or using the mssql-conf tool.
Anybody has an idea what may be wrong?
When running Linux containers from Windows command line/Powershell, the environmental options (-e) require double quotes
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong!Passw0rd>123" -p 1433:1433 --name sql -d mcr.microsoft.com/mssql/server:2017-latest
I have a problem followng [this tutorial](https://hub.docker.com/r/microsoft/mssql-server-linux/
) where I try to connect to my docker hosted MSSQL via sqlcmd.
I executed the following in PowerShell from windows:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e \
'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it \
-d microsoft/mssql-server-linux:latest /bin/bash
Note: "-it" and "/bin/bash" is added due to docker will be stopped automatically if there is no any activity detected.
I ran docker container ls -a to verify it is running:
docker container Is -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92cfc504ab70 microsoft/mssql-server-linux:latest "/bin/bash" 27 minutes ago Up 27 minutes 0.0.0.0:1433->1433/tcp mssql
I ran telnet local-ip:1433 on my host, it is working fine.
Problem lies when I do the following:
docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa \
-P yourStrong(!)Password
Error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout
expired. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP
Provider: Error code 0x2749. Sqlcmd: Error: Microsoft ODBC Driver 17
for SQL Server : A network-related or instance-specific error has
occurred while establishing a connection to SQL Server. Server is not
found or not accessible. Check if instance name is correct and if SQL
Server is configured to allow remote connections. For more information
see SQL Server Books Online..
I also tried to connect in using powershell via my host
Link:https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker
Command:
sqlcmd -S 192.168.0.110,1433 -U SA -P yourStrong(!)Password
Note: 192.168.0.110(got this from running ipconfig in host machine.)
Any help ?
I found out the problems after some trials and errors, and re-reading the documents. I should use double quotes for the arguments when I executed my command in PowerShell.
I was looking into the wrong direction. Initially I executed the command:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e \
'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d \
microsoft/mssql-server-linux:latest
Container stopped automatically by itself every time it starts.
Then, I did some googling and found:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e \
'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it -d \
microsoft/mssql-server-linux:latest /bin/bash
It seemed fine on the surface. It got executed successfully in PowerShell. It didn't stop automatically anymore.If I dig deeper using
docker container logs mssql
to see the log for mssql. No error given, just that I don't see a lots of info given, which led me to think that there were no problems in my command.
But the right way to run these commands is using double quotes.
Link: https://hub.docker.com/r/microsoft/mssql-server-linux/
IMPORTANT NOTE: If you are using PowerShell on Windows to run these commands use double quotes instead of single quotes.
E.g.
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" -p 1401:1433 --name sql1 -d microsoft/mssql-server-linux:2017-latest
I am also able to login using SSMS with:
Server name: Hostip,1401
Username: sa
Password:yourpassword
Try 127.0.0.1 or 0.0.0.0 instead of localhost
For example :
docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P 'yourStrong(!)Password'
docker run command syntax is the following:
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
When you execute the command:
docker run -e 'ACCEPT_EULA=Y' --name mssql -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it -d microsoft/mssql-server-linux:latest /bin/bash
/bin/bash in the end overrides CMD layer defined in the Dockerfile of microsoft/mssql-server-linux image.
So, just start a container without any additional command in the end:
$ docker run -e 'ACCEPT_EULA=Y' --name mssql -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -it -d microsoft/mssql-server-linux:latest
And now you are able to access a MSSQL:
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'yourStrong(!)Password'
1>
I'm new to Docker and I also I had the same issue when I try to connect to the SQL Server container from my application(or sqlcmd app container from Microsoft) which is also running in another Docker container. It looks like each container gets its own subnet IP address, so 'localhost' would never work if you're trying to connect to the SQL from another container.
The command below will give you the full list of IP addresses in the bridge network. You can specify the IP directly in the connection string.
docker network inspect bridge
From your message, it looks the server is not configured to access remotely. Can you follow the way mentioned below to enable it?
Using SSMS (SQL Server Management studio):
In Object Explorer, right-click a server and select Properties.
Click the Connections node.
Under Remote server connections, select the Allow remote connections to this server check box.
Thanks,
Ananda Kumar J.
I want to run sql-server on a mac os x computer. I have successfully build and start a docker container this way:
docker pull microsoft/mssql-server-linux
docker create -v /var/opt/mssql --name volume_mssql microsoft/mssql-server-linux /bin/true
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=SuperPa3ss#1' -p 1433:1433 --volumes-from volume_mssql -d --name sqlserver1 microsoft/mssql-server-linux
It works fine. But i do not know what to do to restart this containers when the computer restarts...
Thanks
** edit **
if i type:
$ docker start volume_mssql
$ docker start sqlserver1
I have no error message, but i see the containers are "exited"
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f5721868bbe1 microsoft/mssql-server-linux "/bin/sh -c /opt/mss…" 15 hours ago Exited (255) 3 minutes ago sqlserver1
e5b88bb02a1b microsoft/mssql-server-linux "/bin/true" 15 hours ago Exited (0) 4 minutes ago volume_mssql
** edit **
$ docker container logs sqlserver1
Dump collecting thread [6] hit exception [6]. Exiting.
Dump collecting thread [7] hit exception [6]. Exiting.
For Autostart, docker container adds --restart always in docker run command.
Change your command to:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=SuperPa3ss#1' --restart always -p 1433:1433 --volumes-from volume_mssql -d --name sqlserver1 microsoft/mssql-server-linux
Your container will start automatically when you restart the docker and PC.
From Terminal:
$ docker pull microsoft/mssql-server-linux
$ docker run -d — name sql_server_demo -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=Dev#998877’ -p 1433:1433 microsoft/mssql-server-linux
$ dokcer image ls
Now Download azure data studio from here,
https://learn.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15
Connect to SQL Server
Server: localhost
Authentication Type: SQL Login
User Name: sa
Password: Dev#99887
Steps by steps:
https://medium.com/macoclock/run-mssql-on-mac-using-docker-39460da701b9
You can find the container name by running: docker ps -a and use the name to start it using docker start <container-name>.
Alternatively, you can specify the container to start automatically by adding --restart always to the run command. This will make the container autostart once you restart the PC.
while trying to log in using this .. mssql -u sa -p mypassword .i get this error, Error: Failed to connect to localhost:1433 - connect ECONNREFUSED 127.0.0.1:1433
I have installed sql server on docker using this https://www.microsoft.com/en-us/sql-server/developer-get-started/java-mac tutorial and started it.
I am using mac os sierra. I have searched all over internet including stackoverflow for this but gotten no answer. The only answer i get is to enable tcp/ip using sql configuration manager, but mac os doesn't have a configuration manager so I can enable the tcp/ip. Kindly assist.
I finally found the solution .. the docker set the memory as 2GB while the MS SQL server requires 3.25GB... All i had to do was go to the Docker preferences and changed the memory to 4GB and it works :). I was using sql server on docker on Mac.
I'm using docker to set up containers and then sql-cli to access SQL server. This is how I resolved that error which I got after providing mssql -u sa -p mypassword.
What I didn't realize at the beginning was a too simple password provided before with setting up a docker container:
docker run -d --name Homer -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=myPassw0rd' -p 1433:1433 microsoft/mssql-server-linux
The Terminal doesn't say this and only after going to docker > Kitematic and checking the logs of the just created container I saw such a security warning. I deleted that container and created a container with a strong password.
Then I got the error after I've started a wrong container (so the connection failed because I was trying to provide the password for a different container). Since then, I prefer to use Kinematic to manage and access my containers. Before I type mssql -u sa -p mypassword in the Terminal and start to work, I just go to docker > Kinematic and Start my container.
In my case the container exited due to an insecure mssql password.
Try reading the container logs.
In my case, I just needed to start the container.
docker start {container_name}
In my case (I was following this tutorial https://database.guide/how-to-install-sql-server-on-a-mac/) the problem was the host address.
I was trying to connect to localhost and I got the ECONNREFUSED message but then I realized that I needed to use the local IP docker assigned to the container (it was something like 192.168.xxx.xxx), so:
mssql -s 192.168..... -o 1433 -u sa -p 'mypassword'
finally worded.
I had the same, in my case I notice that the problem was the PORT, so:
1)Check if the container is running with
docker start "container_name"
2)Then, get the correct PORT with:
docker ps
3) Run it
mssql -s "PORT" -o 1433 -u sa -p "pwd"
I'm adding this answer to complement Krzysztof Tomasz's answer.
I was following this guide: How to Install SQL Server on a Mac
Everything was going well but at the time of connecting to the container with this command:
mssql -u sa -p mypass1
I got:
Error: Failed to connect to localhost:1433 - connect ECONNREFUSED
127.0.0.1:1433
Then I opened Docker app, clicked the container and in the Logs menu I could see the following:
2020-02-05 16:26:45.71 spid20s ERROR: Unable to set system
administrator password: Password validation failed. The password does
not meet SQL Server password policy requirements because it is too
short. The password must be at least 8 characters..
The password I set had only 7 chars. :o)
Now this makes sense.
This is also documented # Microsoft doc here:
Quickstart: Run SQL Server container images with Docker
Solved this problem by removing the container and launching it again...
As I only had one container I ran the following command:
docker rm $(docker ps -a -q)
Then launched sql server image again with a stronger password:
docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MyPass11' -p 1433:1433 microsoft/mssql-server-linux
I resolved this issue by updating the port from 1422 to 1433, I used Kitematic to implement this update.
I had the same, and it was a RAM issue, HOWEVER... 4GB didn't do it for me, for some reason in my case I needed 6, then it worked.
Make sure you have started the container in docker.
Command to start a container: docker start container "containerName"
and then try to connect mssql
I had same problem too, after study the logs with two commands:
docker ps -a
then
docker logs 99373f58f2ff
I understood that problem is related to the password dose not to meet SQL Server password policy! That's is.