This is the first part of – SQL Server 2019 on Linux &Windows containers from zero to an hero!
In this blog series i will explain all you need to know about installing and running SQL Server on containers.
ENJOY.
In part ONE we will learn about containers (Docker , Layers, Docker Engine)
The terms
Term meaning
Docker A program to work with containers
Name of a company
Wrong term for containers
Image Read-only template for an application
Docker registries Stores Docker images
Container An instance of a template
Windows container A container that uses Windows subsystem
Linux container A container that uses Linux subsystem
Why Containers?
- Portable: Run anywhere Docker is supported
- Lightweight then VMs: Reduced disk, CPU, and memory footprint
- Consistent: Consistent image of SQL Server, scripts, and tools
- Efficient: Faster deployment, reduced patching, and less downtime
SQL Server Container

- Bin/libs represent the minimum binaries required to run SQL Server.
- Containers are lightweight vs. an entire virtual machine. containers are from the same image, these files are shared across container
- Docker: Software to run and manage containers & Company: a brand name in IT world
- Containers are lightweight because they have a program that talks directly to the host OS.
Source: SQL Server 2019 Revealed by Bob Ward
The Docker file System
Docker works Layering images on top of each other:
- Your database
- SQL Server Engine
- Engine Dependencies
- Base OS images
Top later: only writable layer
- When a write operation is requested:
- File system driver find what layer the file is in
- If the file is not in the top layer
- It writes a delta to the top layer
- This takes time
Source : https://docs.docker.com/storage/storagedriver/

Docker – Company and Container Runtime
- A program to work with container
- Docker runtime engine was developed by Docker, Inc.
- Docker is an open platform for developing, shipping, and running applications
- Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.
- With Docker, you can manage your infrastructure in the same ways you manage your applications.
- By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.
- What business problem does container technology solve?
- Reliably run software when moved from one computing environment to another.
- By packaging an application and all of its dependencies like binaries, kernel libraries, configuration files, system tools, and so on and creating an entire runtime environment. A container image is created and packaged with the application and all of its dependencies. The image is then deployed as a container at runtime
The Docker Ecosystem: Docker Engine

A client-server application with these components:
- Server: dockerd is the persistent process that manages containers.
- Command line interface (CLI) client: docker command.
- REST API: interfaces that programs can use to talk to the daemon.
Docker architecture

Docker daemon (dockerd) service in Windows
- listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes
- Can also communicate with other daemons to manage Docker services.
Docker client (docker)
- Execute commands and sent to the Docker daemon (SSMS)
- Run docker command: Windows in PowerShell, Linux in shell
- Client can communicate with more than one daemon.
Docker registries
- Stores Docker images.
- Docker Hub is a public registry that anyone can use
- Docker is configured to look for images on Docker Hub by default.
- You can run your own private registry.
- docker push command: image is pushed to your configured registry.
Docker objects
IMAGES
- Read-only template with instructions for creating a Docker container.
- Can create your own images or use images created by others and published in a registry.
- Each instruction in a Dockerfile creates a layer in the image.
- A snapshot of a set of files required to run an application
- Often image is based on another image, with some additional customization.
- SQL Server image based on Ubuntu or Red Hat, Windows
- Portable and consistent.
CONTAINERS
- Runtime instance of an image
- Run as many you like based on the same image.
- Isolated but can communicate with the outside
- Has access by default to all CPU and memory resources.
- Each container has writeable layer but share read-only image layer.
- Start and stop do not affect writeable layer.
- Volumes provide persistence on host.
Windows Container
- A container that uses Windows Subsystem
Linux Container
- A container that uses Linux Subsystem
Containers are Ephemeral and cannot keep data
- You start a container.
- That container starts a process.
- That process performs its mission.
- Process finishes its mission.
- Process terminates.
- Container stops.
Database is the ultimate case not keeping data in container:
- Because of Persistency & Performance
Available Editions of Docker

Installation Choices
Ubuntu \CentOS Linux Server
- VMWare Workstation Player http://www.vmware.com/products/workstation-player/workstation-player-evaluation.html.
- Windows 10 Enterprise, Pro, and Education has built-in Hyper-V as an optional
- enable Hyper-V on Windows 10.
Docker Desktop
- Works with works with Windows and Linux containers
- Requires Windows Professional or Enterprise and Hyper-V
- The best choice!
Windows 2016/19 Server
- Sometimes there are installation issues, only Windows containers
Docker Hub
A container registry: Search for specific Docker
A cloud-based, public repository from Docker, Inc. (like Apple App Store of Docker images)
- Repository: Store your Docker images, for private or public use.
- Teams and organizations: Manage permissions and access to Docker images and repositories by teams /users .
- Official images: Base operating system images, reliable sources.
- Publisher images: from vendors like Microsoft, Oracle, Red Hat, IBM…
- Builds: build and upload Docker images from a Git repository (GitHub, GitLab, and Bitbucket…)
Docker Hub is a public repository, you can pull available Docker images without the need to create a Docker ID.
To push your own custom Docker images to Docker Hub, you need to sign up for a Docker ID

Container Lifecycle
build – docker build command to build a new container image using Dockerfile

syntax of a Dockerfile : https://docs.docker.com/engine/reference/builder/.
push – publish container image to a registry with docker push command.
https://docs.docker.com/engine/reference/commandline/push/.
pull – A container image is downloaded and store on a local server using the docker pull command.
https://docs.docker.com/engine/reference/commandline/pull/.
run – To run a container based on an image, use the docker run command.
Use docker client to manage, Monitor, interact
.
Docker Image Naming Conventions
REGISTRY [: PORT]/REPO/IMAGE[:TAG]
public container registries.
• Microsoft Container Registry (MCR): mcr.microsoft.com
• Amazon Elastic Container Registry (ECR): dkr.<region>. amazonaws.com
• Google Container Registry (GCR): gcr.io
From SQL 2019 Microsoft, including SQL Server, publishes their container images MCR.
Images are on the list on Docker Hub, but the images themselves are on mcr.microsoft.com.
Repository (or repo) the name of the software company.
Example: docker.io/microsoft is Microsoft’s official repo on Docker Hub.
Tag
Tags further identify the contents of the Docker image
Tip: Specify a tag is because you will never know what latest image you get from the public container registry
If don’t provided Docker will use latest tag.
docker run hello-world
is same as
docker run hello-world:latest
docker pull microsoft/mssql-server-linux
is same as
docker pull docker.io/microsoft/mssql-server-linux:latest
Refer to Microsoft Container Registry (MCR) to download image:
docker pull mcr.microsoft.com/mssql/server:latest
DAVID I.