I am playing around docker container from last couple of days on my windows machine with docker desktop tool, seems to be fairly simple and working fine. I decided to go to next step where I want to connect asp.net core web api to SQL server running inside docker container.
Reading docker material and surfing internet, I found a simple command to download and run SQL Server Ubuntu/Linux container. Here is the syntax I used,
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MySuperStrongPassword1!' -p 1432:1433 --name sqltest -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu
Command ran successfully and I can see container from “docker ps -a” and in docker dashboard.
However containers stop working with status EXITED (1). Every time I start container either from command prompt or docker dashboard it automatically stops with status Exited (1).
What went wrong !! The command is very simple and I typed it correct too. After reading few articles over internet I found issue at https://github.com/Microsoft/mssql-docker/issues/199
According to Github, if you are working on windows command prompt or powershell , you should use double quote instead of single quote. The correct command is
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=MySuperStrongPassword1!" -p 1432:1433 --name sqltest -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu
Explanation
When you run SQL server withing container you must accept terms and condition. The argument -e “ACCEPT_EULA=Y” does the same thing however when you use single quote instead of double quote, it does not set condition acceptance to true and hence SQL container stops.
Happy Programming !!