Skip to content

About

This repository contains code and Docker templates that spins up the latest SQL Server inside a docker host and attaches an AdventureWorks database.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

THE CONCEPT

As we all know today, data rules everything and there is an increasing demand for Data Scientist and Analyst all over the world because of the emergence of AI into the mainstream.

At Codewired Inc., data rules everything around us and we know the importance of equipping Analysts, Data Scientist & Engineers with the right tools.

This repository contains all the orchestration needed to spin up a fully working SQL Server 2022 linux container with docker on any mac, linux or windows (using WSL) box, prepared with an a subset version of the popular Microsoft's AdventureWorks database. AdventureWorks is a very good dummy database for developers and architects as well as data scientists and engineers.

Prerequisites

Install Docker Desktop or Rancher Desktop (Preferably). For those who don't have the capacity to install Docker desktop, installing Docker without Docker Desktop is achievable, especially on mac & Linux-based systems or by leveraging Windows Subsystem for Linux (WSL) on Windows. If you have Docker Desktop or Rancher Desktop installed (for Rancher set it to use Docker daemon), you can skip to 'Build and run your database'

On Linux:

Uninstall any previous Docker installations: Ensure no remnants of Docker Desktop or other Docker installations exist. Install Docker Engine: use this link if you use Ubuntu (https://docs.docker.com/engine/install/ubuntu/) or follow the official Docker documentation for installing Docker Engine on your specific Linux distribution (e.g., Debian, Fedora, openSUSE, LinuxMint, CentOS, RHEL). This typically involves: (i) Setting up the Docker repository. (ii) Installing the docker-ce package. Add your user to the docker group: This allows you to run Docker commands without sudo. sudo usermod -aG docker $USER Log out and log back in: This applies the group changes. Verify the installation: Run a simple command like docker run hello-world.

On Windows using WSL2:

Install WSL2 and a Linux distribution: Follow Microsoft's instructions to install WSL2 and a preferred Linux distribution like Ubuntu. Open your WSL terminal: Access your installed Linux distribution through the Windows Terminal. Install Docker Engine within WSL: Follow the Linux installation steps mentioned above within your WSL terminal to install Docker Engine on your chosen Linux distribution. Follow same steps for Linux above to add your user to the docker group within WSL. Restart your WSL distribution or log out and back in: This applies the group changes within WSL. Verify the installation: Run docker run hello-world in your WSL terminal.

Important Notes:

Windows Containers (without WSL): For running Windows containers without Docker Desktop or WSL, you would typically use Docker static binaries, enable Hyper-V and Containers features, and manage the Docker daemon manually. This approach does not support Linux containers or advanced features like buildx or docker compose. Alternative Runtimes (macOS): On macOS, you can use alternatives like Colima, which provides a container runtime compatible with Docker without requiring Docker Desktop. Docker Compose: You may need to install Docker Compose separately if you require its functionality, as it's often a separate component from the core Docker Engine. Click here (https://docs.docker.com/compose/install/linux/)

Build and run your database with AdventureWorks data.

Ensure the config directory in the docker folder contains these three files configure-db.sh entrypoint.sh testdata.sal

When you're ready, start your SQL Server by running command below from inside the docker folder: docker compose up --build Check out the scripts folder and try out some cool this on the AdventureWorks database. The data will persist even if you restart your box, just run the container again from your docker GUI or console, thats it!.

Push image to Docker Hub and share with others

First, build your image using the provided Dockerfile, like so: docker build -t sqlserver-poc ., and unlike docker compose, this just builds the image and get's it ready to be pushed. If your testdata.sql is large then the resulting image will be as well. The default architecture in the Docker file is linux/amd64 which is accepted image architecture for Linux hosts and this works perfectly on macOs silicon chips as well. If you desire to run it explicitly and specifically for a particular architecture you can pass in the platform build argument while building the docker file: docker build -t sqlserver-poc --build-arg PLATFORM=linux/arm64 ..

Then, tag and push it to your registry, lik so: docker tag sqlserver-poc example.com/sqlserver-poc and then docker push example.com/sqlserver-poc

Consult Docker's getting started docs for more detail on building and pushing.

Now your team can pull and run your image locally and start hacking with the database right away. For you or anyone you share this image with to successfully run it, they must pass in some basic environment variables, ports and volume mounts like so:

docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Passw0rd!' -e 'MSSQL_PID=Developer' -e 'MSSQL_TCP_PORT=1433' \
-p 1433:1433 \
--hostname sqldocker \
--name my-sqlserver \
-v mssql-data:/var/opt/mssql \
example.com/sqlserver-poc:latest

If you desire to run your containers in Kubernetes, the best option is to create a persistent disk and volume claim and then run the pod as a stateful set pointing to the volume. send me a message if you need help with that (code@codewired.me)

About

This repository contains code and Docker templates that spins up the latest SQL Server inside a docker host and attaches an AdventureWorks database.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages