Last active
January 4, 2022 14:15
-
-
Save MartinMSPedersen/d5d30a8e8e77d5f7905506c3bf188197 to your computer and use it in GitHub Desktop.
Download, install. configure and run Microsoft SQL-Server in less than one minute using Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo '[+] Stop running mssql' | |
docker container rm -f mssql &>/dev/null | |
echo '[+] Remove Docker image' | |
docker image rm mcr.microsoft.com/mssql/server:2019-latest &>/dev/null | |
echo "[+] Start time $(date +%R:%S)" | |
START=$(date +%s) | |
echo '[+] Download image from Docker hub (1.55GB)' | |
docker pull mcr.microsoft.com/mssql/server:2019-latest &>/dev/null | |
echo '[+] Start new mssql' | |
docker container run --name mssql --rm -d -e 'TZ=Europe/Copenhagen' -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=godt_hemmeligt_k0de0Rd" -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest &>/dev/null | |
echo '[+] Wait 20 seconds for the database to be ready' | |
sleep 20 | |
echo '[+] Connect to database and run some SQL' | |
echo 'SELECT 2+2' | |
echo 'SELECT current_timestamp' | |
docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'godt_hemmeligt_k0de0Rd' << EOT | |
SELECT 2+2; | |
GO | |
SELECT current_timestamp; | |
GO | |
EXIT | |
EOT | |
echo "[+] End time $(date +%R:%S)" | |
END=$(date +%s) | |
date +%R:%S | |
echo "Time used: $((END-START)) seconds" |
Author
MartinMSPedersen
commented
Jan 4, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment