Docker Container exit immediately after running - sql-server

I'm a Docker newbie and tried to resolve the issue after checking similar SO questions without success. So please don't mark it as a duplicate .
Issue :
The container always exits immediately after its created and running.
I have tried to run the mssql instance using command
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Technocrat123’ -p 1433:1433 -d microsoft/mssql-server-linux
when trying as similar SO link link
$ docker run -t -d --name microsoft/mssql-server-linux 0adcdf822722
got the following error ,
Unable to find image '0adcdf822722:latest' locally
docker: Error response from daemon: repository 0adcdf822722 not found: does not exist or no pull access.
when tried to kill the process referring link1
Kill: illegal process id: PID
I'm using a mac machine. Thanks in advance.
Edit :
After running the log after run command like
docker logs 0adcdf822722
it shows
This is an evaluation version. There are [160] days left in the evaluation period.
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.
But already in the run command I have set 'ACCEPT_EULA=Y'.

Your password (such as Technocrat123) doesn't meet the complexity requirements. So try adding a non-alphanumeric characters such as exclamation point (!). Secondly, use double quotes instead of single.
To check for errors, run: docker logs ID (where ID is container ID from docker ps).

This worked for me:
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Sprpwd1234" --name sql_server_dev -p 1433:1433 -d store/microsoft/mssql-server-linux:2017-GA
Using (") instead of ('). Running Docker on Windows 10.

There is a typo in the command you are running:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Technocrat123’ -p 1433:1433 -d microsoft/mssql-server-linux
'Technocrat123’ should be 'Technocrat123'. The typo is in the end: ’ vs '.
The correct command is:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Technocrat123' -p 1433:1433 -d microsoft/mssql-server-linux

I was running Docker on Mac and trying to install sql-server. Initially, I was pasting the command provided here - https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker changing password. Then I would try to run the docker image. This gave me the said error "This is an evaluation version.....". I did an additional step, after running the command on the above link. I ran it again as docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Very_StrongPassword' -p 1401:1433 microsoft/mssql-server-linux:2017-latest. This kicked off installation of sql-server. This installation takes around 20-30 mins. Then the docker image is ready to use.

Related

Install SQL Server on Mac

I am on the following page:
https://www.quackit.com/sql_server/mac/install_sql_server_on_a_mac.cfm
In step 1, it says to use the following Docker command in a terminal:
docker pull microsoft/mssql-server-linux
However, that command is outdated and did not work.
I made my way to the following URL:
https://hub.docker.com/_/microsoft-mssql-server
I used the following command I found there:
docker pull mcr.microsoft.com/mssql/server:2019-latest
Using the command directly above, I could see the terminal pulling and completing the installation.
So now in step 2, it says to use the following Docker command:
docker run -d --name Homer -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=myPassw0rd' -p 1433:1433 microsoft/mssql-server-linux
But then says if I used a different container, I have to replace "microsoft/mssql-server-linux" with my container image.
This is where I'm stuck.
I tried to use the following:
docker run -d --name Homer -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=myPassw0rd' -p 1433:1433 mcr.microsoft.com/mssql
But I get the following error:
Unable to find image 'mcr.microsoft.com/mssql:latest' locally
docker: Error response from daemon: manifest for mcr.microsoft.com/mssql:latest not found: manifest unknown: manifest tagged by "latest" is not found.
What am I doing wrong?
When you pulled the image, you used:
mcr.microsoft.com/mssql/server:2019-latest
When you ran the container, you used something else:
docker run -d ... mcr.microsoft.com/mssql
Why did you shorten this and leave stuff out of it? Docker can't read your mind or perform auto-complete for you. Try:
docker run -d ... mcr.microsoft.com/mssql/server:2019-latest

Running mssql-server-linux image in QUIET mode

I am using microsoft/mssql-server-linux:2017-latest MS SQL docker image.
It works fine, but outputs dozens of information, which I would be happy to omit. I couldn't find command line or environment options to run it in quiet mode, can anyone help me?
FYI command line is:
docker run -e ACCEPT_EULA=Y -e SA_PASSWORD="<BestPwd>" -e MSSQL_PID=Express -it microsoft/mssql-server-linux:2017-latest
Just appending -q didn't help..
UPD
I know containers can be run in daemon mode, what I need is to reduce log to warnings level and not removing it completely.
Also I would appreciate generic methods; which are NOT connected with stdout redirection or grepping / filtering output.
You can use -d option to run the container in the background using below command.
docker run -e ACCEPT_EULA=Y -e SA_PASSWORD="<BestPwd>" -e MSSQL_PID=Express -d microsoft/mssql-server-linux:2017-latest
If you want to see the logs then you can give docker logs -f 'containerid'

Login fails for SA sql server linux docker

I try to use sql server on docker, linux. I start the container like this:
docker run -d -p 1433:1433 -e sa_password="12345qwerASDF" -e ACCEPT_EULA=Y --name sql-server --hostname sql-server microsoft/mssql-server-linux:2017-latest
When I try to connect, all I get is "Login failed for user 'sa'"
Tried with different password, with and without double and single quotes...
Finally I got it to work:
docker run --name sqlserver --hostname sqlserver -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=1StrongPwd!!" -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest
I guess it should be MSSQL_SA_PASSWORD and not SA_PASSWORD
The documentation isn't clear in that part...
Your password 12345qwerASDF doesn't meet complexity requirements. Try adding a non-alphanumeric characters such as exclamation point (!).
To check for errors, run: docker logs ID (where ID is container ID from docker ps).
For docker-compose file
i was facing problem with sa user login failed i fix it by adding
depends_on:
- db
here's my full version of docker-compose file
version: '3.1'
services:
colour-api:
build: .
environment:
DBServer: "ms-sql-server"
ports:
- "8080:80"
depends_on:
- ms-sql-server
ms-sql-server:
image: mcr.microsoft.com/mssql/server
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "Pa55w0rd2019"
ports:
- "1444:1433"
Follow this link for more details
https://docs.docker.com/compose/aspnet-mssql-compose/
I got the same error. Stop the sql server services running in your local. Then You can login to sql server(linux) via docker(dbeaver)
1-) I got the error
2-) Stop the sql server services running in your local
3-) Then You can login to sql server(linux) via docker(dbeaver)
I hope it was helpful
Try this :
docker run -e "ACCEPT_EULA=Y" -e "sa_password=12345qwerASDF" -p 1433:1433 --name sql-server --hostname sql-server -d microsoft/mssql-server-linux:2017-latest
IMPORTANT NOTE: If you are using PowerShell on Windows to run these
commands use double quotes instead of single quotes.
Source : https://hub.docker.com/r/microsoft/mssql-server-linux/
I solved my problem with this notes
In formal doc used SA_PASSWORD !!!, but MSSQL_SA_PASSWORD is true (Microsoft team, what are doing?!!!!)
As a docker "[Configuration/Requirements for Microsoft SQL Server][1]" said: " A strong system administrator (SA) password: At least 8 characters including uppercase, lowercase letters, base-10 digits and/or non-alphanumeric symbols."
In Linux, use single quote for define password .
Be sure, before you run "docker run .." , the volume of "data" which you mount from host to container must be clean (if you have it!).
Here is a sample of “docker run” for creation Microsoft SQL Server container.
docker run
-e ACCEPT_EULA=Y
-e MSSQL_SA_PASSWORD='Mssql!Passw0rd'
-e MSSQL_DATA_DIR=/var/opt/mssql/data
-e MSSQL_PID='Developer'
-e MSSQL_TCP_PORT=1433
-p 1433:1433
-v /var/opt/mssql/data:/var/opt/mssql/data
-v /var/opt/mssql/log:/var/opt/mssql/log
-v /var/opt/mssql/secrets:/var/opt/mssql/secrets
--name mssql_2017
-d mcr.microsoft.com/mssql/server:2017-latest
for checking an instance of SQL Server ...
docker exec -it mssql_2017 /bin/bash
cd /opt/mssql-tools/bin/
./sqlcmd -S localhost -U SA -P 'Mssql!Passw0rd'
select ##version
go
I hope this hints can help you.
The docker volume used for the mssql service could be corrupted.
In a docker setup using mcr.microsoft.com/mssql/server:2019-latest
I have encountered a similar problem. Although I had no problem
connecting to the server from a container built from the command line the issue persisted for the docker container.
Removing the volume and recreating the container did the trick.
docker run --name SQLServer -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=“Yourpassword” -e MSSQL_PID="Express" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
Same thing happened to me but the problem was I had a windows desktop version of MSSQL and I forgot to stop the service before connecting to the docker version.

Attempting to run SQL Server on Docker for Mac: Event not found

I don't know what I am doing wrong. Have made many attempts to run SQL Server in Docker, but all have been unsuccessful. Here's a copy of the text in my terminal for the last attempt:
Jennifers-MacBook-Pro:~ ziema26$ sudo docker pull microsoft/mssql-server-linux
Password:
Using default tag: latest
latest: Pulling from microsoft/mssql-server-linux
Digest: sha256:6c4a13ade5778251bfba648c21fa7968f02aa5b86a7d8b66be710faf8626b38f
Status: Image is up to date for microsoft/mssql-server-linux:latest
Jennifers-MacBook-Pro:~ ziema26$
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<password>" -p 1433:1433 --name mydb2 -d microsoft/mssql-server-linux
-bash: !: event not found
In the examples found on the mssql-server-linux Dockerhub page, it recommeds using a strong password...with the example yourStrong(!)Password . If you try and connect to your container passing in special characters like (, ! or ) you'll have problems. Specifically ! is a special character in bash, which refers to the previous command resulting in that error you're receiving, -bash: !: event not found
You'll need to escape these characters, e.g docker exec -it mssql-container-name /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P yourStrong\(\!\)Password or use single quotes.

Linux sql server Docker stops after few seconds

This is the command I execute but the container just stop after few seconds: docker run -it -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=dockermssql" -p 1433:1433 -v sqlvlm:/var/opt/mssql --name sql1 -d microsoft/mssql-server-linux
Your password (e.g. dockermssql) doesn't meet the complexity requirements. So try adding a non-alphanumeric characters such as exclamation point (!).
To check for errors, run: docker logs ID (where ID is container ID from docker ps), or run container without -d.
Remove detatched mode "-d" so it runs in "foreground" mode, this should then give you your stdout, stderror etc to your terminal and you may see some errors logged which can hopefully point you in the right direction.

Resources