For one of my pet projects, I need to use a simple SQL Server database to store the data.
As I wanted to do it for a long time, I’ve decided to use docker to get a SQL Server container.
I don’t know by heart the command line to setup the container (pulling the image is easy but I know there are some parameters to use, etc.) so after a quick look on Internet, I found this page:
This page (or, at least, this tab) is explaining the commands to use on a Bash system. As I’m running Windows on my machine, I just decided to “sudo” part and ran the following command:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MySuperStrongPassword1!' -p 1432:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
The container started correctly but, after a few seconds, it was shown as “Exited (1)” as you can see on the following image:
Weird, what happened ?! Fortunately, Docker provide a very useful command (docker log CONTAINER_ID) to show the logs regarding a container:
Hum… The problem is that Licence Agreement has not been accepted but how is that possible? I thought “ACCEPT_EULA=Y” was dedicated to that ?
After some research on the Web, I found this issue on Github which was exactly my problem:
The workaround proposed here, if you are using the command line / Powershell, is to use double quotes (and not single quotes) to specify parameters so the command line become:
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=MySuperStrongPassword1!" -p 1432:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
And it worked! This is a simple trick and well documented in fact as it’s also written on the official page of the SQL Server image:
As a conclusion, the only thing I can say is just to never be in a hurry and RTFM 😀
Happy coding !