Sign inSign up

archety/sqlserver-emplyees

By archety

•Updated 21 days ago

SQL Server 2022 with auto-initialized CompanyDB for Docker, SQL and backend training labs.

Image
Languages & frameworks
API management
0

76

archety/sqlserver-emplyees repository overview

⁠SQL Server Employees - archety/sqlserver-emplyees

A ready-to-use Microsoft SQL Server 2022 Docker image with an automatically initialized sample database containing employees and departments.

This image is designed for learning, backend development and Docker training labs, removing the need to manually configure SQL Server or populate a database before starting an exercise.

At container startup, SQL Server is launched, its availability is checked automatically, and the initialization script creates and populates the CompanyDB database.


⁠Features

  • Microsoft SQL Server 2022
  • Automatic database initialization at container startup
  • Built-in SQL Server readiness check
  • Preconfigured CompanyDB database
  • Department and Employee relational tables
  • Foreign key relationship between employees and departments
  • Sample dataset included
  • Persistent storage compatible with Docker volumes
  • Ideal for SQL, Docker, REST API and Entity Framework labs
  • Ready to be used from .NET, Java, Node.js or any SQL Server-compatible client

⁠Database Structure

The image automatically creates the following database:

CompanyDB
⁠Department
ColumnTypeDescription
IdINTPrimary key, auto increment
DepNameVARCHAR(100)Unique department name
DepLocationVARCHAR(255)Department location
⁠Employee
ColumnTypeDescription
IdINTPrimary key, auto increment
FirstNameVARCHAR(255)Employee first name
LastNameVARCHAR(255)Employee last name
EmployeeRoleVARCHAR(100)Job role
EmployeeCodeVARCHAR(100)Unique employee code
DepartmentRefINTForeign key to Department

Relationship:

Department (1) -------- (*) Employee

Deleting a department also deletes its associated employees through ON DELETE CASCADE.


⁠Sample Data

The database contains 6 departments:

  • Engineering
  • Human Resources
  • Marketing
  • Finance
  • Operations
  • Research & Dev

and 20 sample employees distributed across those departments.

This makes the image immediately usable for exercises involving:

  • SELECT
  • WHERE
  • ORDER BY
  • JOIN
  • GROUP BY
  • aggregate functions
  • primary and foreign keys
  • CRUD operations
  • ORM mapping
  • Entity Framework Core

⁠Quick Start

Pull the image:

docker pull archety/sqlserver-emplyees:latest

Run the container:

docker run -d \
  --name sqlserver-employees \
  -e ACCEPT_EULA=Y \
  -e SA_PASSWORD="YourStrongPassword123!" \
  -p 1433:1433 \
  archety/sqlserver-emplyees:latest

The SA_PASSWORD environment variable is required by SQL Server.
For real projects, use a secure password and never commit production credentials into source control.


⁠Docker Compose

Example:

services:
  sqlserver:
    image: archety/sqlserver-emplyees:latest
    container_name: sqlserver
    ports:
      - "1433:1433"
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: "YourStrongPassword123!"
    volumes:
      - data_sqlserver:/var/opt/mssql

volumes:
  data_sqlserver:

Start the environment:

docker compose up -d

Check the running container:

docker ps

View startup logs:

docker logs sqlserver

⁠Automatic Initialization

When the container starts, the included entrypoint script:

  1. starts SQL Server;
  2. waits until SQL Server accepts connections;
  3. verifies availability using a simple SELECT 1;
  4. executes the bundled import.sql script;
  5. creates CompanyDB if it does not already exist;
  6. creates the required tables if they do not already exist;
  7. inserts the sample dataset if the tables are empty.

The initialization script is intentionally simple and readable, making it suitable for educational use and demonstrations.


⁠Connecting to SQL Server

Typical connection parameters:

Server: localhost,1433
User: sa
Password: <your SA_PASSWORD>
Database: CompanyDB

Example .NET connection string:

Server=localhost,1433;Database=CompanyDB;User Id=sa;Password=YourStrongPassword123!;TrustServerCertificate=True;

This makes the image particularly useful when learning ASP.NET Core and Entity Framework Core.


⁠Example Queries

⁠List all employees
SELECT *
FROM Employee;
⁠List departments
SELECT *
FROM Department;
⁠Employees with their department
SELECT
    e.FirstName,
    e.LastName,
    e.EmployeeRole,
    d.DepName,
    d.DepLocation
FROM Employee e
INNER JOIN Department d
    ON e.DepartmentRef = d.Id;
⁠Count employees by department
SELECT
    d.DepName,
    COUNT(e.Id) AS Employees
FROM Department d
LEFT JOIN Employee e
    ON e.DepartmentRef = d.Id
GROUP BY d.DepName;

⁠Use Cases

This image was created primarily for educational and training scenarios, including:

  • Docker fundamentals
  • Docker volumes and persistent databases
  • Microsoft SQL Server exercises
  • SQL relational database training
  • Backend REST API development
  • ASP.NET Core projects
  • Entity Framework Core
  • Repository Pattern exercises
  • Clean Architecture labs
  • Database migrations and ORM comparisons
  • Full-stack development labs
  • Docker Compose demonstrations

It can also be used as a simple disposable SQL Server environment for prototypes and development tests.


⁠Video Playlist

A complete playlist is available on the Archety YouTube channel to understand the concepts behind this project and follow the related hands-on exercises:

https://www.youtube.com/playlist?list=PLoZNHBEyxFQF_WPhyI1dBR6H3dBkOUqwO⁠


⁠Docker Hub

Image:

archety/sqlserver-emplyees

Pull:

docker pull archety/sqlserver-emplyees:latest

⁠Educational Purpose

This project is primarily intended for:

  • classroom demonstrations;
  • technical training;
  • self-study;
  • workshops;
  • backend development exercises;
  • Docker and database labs.

It is deliberately kept simple enough to let students focus on the interaction between containers, SQL Server, relational data and backend applications.


⁠License

This project is released under the MIT License.

You are free to use, modify and redistribute the project for educational, personal and commercial purposes, provided that the original copyright and license notice are retained.

See the LICENSE file in the source repository for the complete license text.


⁠Author

Archety

Software Development, DevOps and Technical Training.

Tag summary

Content type

Image

Digest

sha256:0c8d8bb20…

Size

596.9 MB

Last updated

21 days ago

docker pull archety/sqlserver-emplyees