Running SQL Server in a container on Github Actions
In building out integration tests for DataStation recently I set up SQL Server. I didn't think this would be possible because Microsoft (and Oracle and IBM) normally require you to manually sign in to download their databases. However, Microsoft provides Docker images and allows you to accept their UELA in the command line.
So in my Github Actions run steps I added a call to Docker run:
# Start up sqlserver - run: docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=1StrongPwd!!" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
image docs say to set a
variable instead of
MSSQL_SA_PASSWORD but I tried that
and couldn't connect when setting that or
Once this Docker image is running you'll be able to connect to
master database with the
sa user and
the above password. It's important that if you use a different
password it fulfills all the complexity requirements listed on the
Docker image documentation.
Now in Go code you can connect
with the connection
The only difficult part of this recipe once is that it's hard to debug when you've set up the password incorrectly (not fulfilling complexity requirements) or if you mistype an environment variable. Maybe if I checked the Docker logs for the SQL Server container it would have given me useful information. Instead I stumbled toward a working setup through guess and check.
Questions? Feedback? Feel free to reach the author at email@example.com.