This repository contains a Docker Compose setup to create a SQL Server instance and automatically import the AdventureWorks database from a .bak
file.
Before you begin, ensure you have the following installed on your machine:
Clone this repository to your local machine:
git clone https://github.com/sero-dev/adventure-works
Download the AdventureWorks2022 backup file from a trusted source. Depending on which backup you use, you may need to rename the file to AdventureWorks2022.bak
.
Place your AdventureWorks2022.bak file in a directory named import-data within the root of the repository. The structure should look like this:
adventure-works/
├── docker-compose.yml
├── README.md
└── import-data/
├── .gitkeep
└── AdventureWorks2022.bak
The docker-compose.yml file uses the following environment variables for SQL Server configuration:
- MSSQL_SA_PASSWORD: The password for the SA (System Administrator) account.
- ACCEPT_EULA: Set to Y to accept the End User License Agreement.
You can modify these directly in the docker-compose.yml file if needed. If you do modify the MSSQL_SA_PASSWORD
variable, find and replace the password on the docker compose file. There should be a total of 3 references for that variable.
Run the following command to start the Docker containers and import the AdventureWorks 2022 database:
docker-compose up
Docker Compose will perform the following steps:
- Start a SQL Server instance.
- Use the import-data service to wait for the SQL Server instance to be ready.
- Import the AdventureWorks2022.bak file into the SQL Server instance.
Once the setup is complete, you can connect to the SQL Server instance using any SQL Server client. Use the following connection details:
Server: localhost
Port: 1433
Username: SA
Password: YourStrong!Passw0rd (or the password you set in docker-compose.yml)
You can verify that the AdventureWorks database has been successfully imported by connecting to the SQL Server instance and running a query to list the databases:
SELECT name FROM sys.databases;
You should see AdventureWorks in the list of databases.
To stop and remove the Docker containers, run:
docker-compose down
If you encounter issues, ensure that:
- Docker and Docker Compose are correctly installed.
- The AdventureWorks2022.bak file is correctly placed in the import-data directory.
- The environment variables in docker-compose.yml are correctly configured.