SQL Server 2022 with auto-initialized CompanyDB for Docker, SQL and backend training labs.
76
archety/sqlserver-emplyeesA 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.
CompanyDB databaseDepartment and Employee relational tablesThe image automatically creates the following database:
CompanyDB
| Column | Type | Description |
|---|---|---|
Id | INT | Primary key, auto increment |
DepName | VARCHAR(100) | Unique department name |
DepLocation | VARCHAR(255) | Department location |
| Column | Type | Description |
|---|---|---|
Id | INT | Primary key, auto increment |
FirstName | VARCHAR(255) | Employee first name |
LastName | VARCHAR(255) | Employee last name |
EmployeeRole | VARCHAR(100) | Job role |
EmployeeCode | VARCHAR(100) | Unique employee code |
DepartmentRef | INT | Foreign key to Department |
Relationship:
Department (1) -------- (*) Employee
Deleting a department also deletes its associated employees through ON DELETE CASCADE.
The database contains 6 departments:
and 20 sample employees distributed across those departments.
This makes the image immediately usable for exercises involving:
SELECTWHEREORDER BYJOINGROUP BYPull 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_PASSWORDenvironment variable is required by SQL Server.
For real projects, use a secure password and never commit production credentials into source control.
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
When the container starts, the included entrypoint script:
SELECT 1;import.sql script;CompanyDB if it does not already exist;The initialization script is intentionally simple and readable, making it suitable for educational use and demonstrations.
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.
SELECT *
FROM Employee;
SELECT *
FROM Department;
SELECT
e.FirstName,
e.LastName,
e.EmployeeRole,
d.DepName,
d.DepLocation
FROM Employee e
INNER JOIN Department d
ON e.DepartmentRef = d.Id;
SELECT
d.DepName,
COUNT(e.Id) AS Employees
FROM Department d
LEFT JOIN Employee e
ON e.DepartmentRef = d.Id
GROUP BY d.DepName;
This image was created primarily for educational and training scenarios, including:
It can also be used as a simple disposable SQL Server environment for prototypes and development tests.
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
Image:
archety/sqlserver-emplyees
Pull:
docker pull archety/sqlserver-emplyees:latest
This project is primarily intended for:
It is deliberately kept simple enough to let students focus on the interaction between containers, SQL Server, relational data and backend applications.
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.
Archety
Software Development, DevOps and Technical Training.
Content type
Image
Digest
sha256:0c8d8bb20…
Size
596.9 MB
Last updated
21 days ago
docker pull archety/sqlserver-emplyees