Sign inSign up

tohun/mssql-lab

By tohun

•Updated 4 months ago

mssql lab docker images

Image
0

1.4K

tohun/mssql-lab repository overview

⁠🎓 What is this Image?

Think of this Docker image as a ready-to-go SQL Server that automatically does your homework setup for you.

Instead of installing Microsoft SQL Server manually and running a huge script to create tables and fill them with fake students, grades, and payments, this image does it all automatically when it starts.

⁠🚀 Quick Start: How to Run It

To use this image, you need to run a command in your terminal (PowerShell, Command Prompt, or Terminal).

Here is the best command to copy and paste to get started immediately:

docker run -e "INIT_DEFAULT_DB=TRUE" -e "LAB=1" -e "VARIANT=5" -p 1433:1433 --name sql_lab_1 tohun/mssql-lab


⁠⚙️ Settings (Environment Variables)

You can customize how the database is built by changing the "Environment Variables" (the -e flags in the command above). Here is what each one does:

SettingDefaultDescription
INIT_DEFAULT_DBFALSEImportant: You must set this to TRUE if you want the container to automatically create your tables and data. If you leave it FALSE, you get an empty server.
LAB1Tells the container which lab script to run. If you are doing Lab 1, set this to 1. If you are doing Lab 4, set this to 4. This picks the correct .sql file to execute.
VARIANT1This is your personal "Variant" number. It changes the random data generation (like how many students or how much money is in the payments table), so your database looks slightly different from your classmate's.
DB_NAMEDEFAULT_DATABASEThe name of the database that will be created. You can change this to MyLabDB or anything you like (mostly used for Lab 1).
MSSQL_SA_PASSWORDLab_Password!123The master password to log in. You can change it, but make sure it is strong (SQL Server requires complex passwords), or just use the default provided here.

⁠🔌 How to Connect

Once the container is running, you can connect to it using SSMS (SQL Server Management Studio), DBeaver, or Azure Data Studio.

  • Server / Host: localhost,1433
  • Authentication: SQL Server Authentication
  • Login (User): sa
  • Password: Lab_Password!123 (or whatever you changed it to)
⁠🧠 How It Works (Under the Hood)
  1. Starts SQL Server: The container starts the Microsoft SQL Server engine.
  2. Waits: It pauses and checks every second to see if the server is ready to accept commands.
  3. Checks Settings: If you set INIT_DEFAULT_DB=TRUE, it looks at which LAB number you chose.
  4. Runs the Script: It automatically runs the SQL script (like setup_lab_1.sql) to create tables (Students, Payments, etc.) and generates thousands of rows of fake data based on your VARIANT.
  5. Sets a Flag: It creates a small hidden file called setup_completed.flag. This ensures that if you restart the container, it doesn't try to overwrite your database again.
⁠💡 Tips for Running It Better
  • Don't lose your data: If you delete the container, your database disappears. To keep your work safe, add a "volume" to your command. This saves the database files on your actual computer. Add this to your docker run command: -v sql_data:/var/opt/mssql/data
  • If you get a connection error: Wait 10-20 seconds after starting the container. SQL Server takes a moment to wake up and run the setup scripts. You can check the progress by running docker logs sql_lab.
  • Custom Scripts: If you have your own .sql files you want to run automatically, you can put them in a folder and map it to /docker-entrypoint-initdb.d inside the container. The image is built to run any extra SQL files found there automatically!

Tag summary

Content type

Image

Digest

sha256:549b4b483…

Size

589.2 MB

Last updated

4 months ago

docker pull tohun/mssql-lab