Getting Started with Linux Containers for SQL Server - Part 2
In our first tip in this series, we looked at an overview of Containers and how to setup a Windows machine to be able to use Containers. In this tip we will take this a step further and show how Containers can be used by a SQL Server DBA on a Linux system.
In a previous tip on Getting Started with Windows Containers for SQL Server - Part 1, you've setup Docker in a Windows Server 2016 environment. Since Docker was originally designed to virtualize the Linux operating system kernel, it would be beneficial to learn how to work with Docker in a Linux environment. Plus, with SQL Server 2017 and higher support on the Linux operating system, you will start to see an increase in adoption of Linux to run SQL Server databases.
Setup Docker on Linux
Here's a high-level overview of the process involved in setting up Docker on Linux. It is a clean installation of the Linux CentOS 7 operating system and directly connected to the Internet.
- Update Linux system packages and install the required dependencies
- Add the Docker stable repository to your system
- Install the Docker CE engine
- Start the Docker daemon and enable it to automatically to launch on server boot
Since there are different Linux distributions, the commands used in this tip will be specific to the RedHat/CentOS Linux distribution.
Step #1: Update Linux system packages and install the required dependencies
Run the command below to update the Linux system packages and install the required dependencies. Docker leverages the Device Mapper storage driver for advanced volume and storage management capabilities in Linux. This allows for images and containers storage management. LVM2 or Logical Volume Manager - as the name implies - provides common logical volume management for the Linux kernel such as RAID configuration, volume resizing, volume snapshots and the likes.
sudo yum update sudo yum install yum-utils device-mapper-persistent-data lvm2
Step #2: Add the Docker stable repository to your system
Run the command below to add the Docker stable repository to your system. A repository configuration file contains information about the collection of packages together with the dependencies that Docker will use.
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Note that the repository points to the free Docker Community Edition (Docker CE). This is the recommended path if you are just starting out with Docker and containers. Once you have gained enough experience working with Docker and ready to deploy containers in a production environment, you can easily switch to the paid Docker Enterprise Edition (Docker EE) for support.
Step #3: Install the Docker CE engine
Run the command below to install the Docker CE engine. This will download the Docker CE engine installation packages for Linux. Once the download completes, it will automatically run the installation.
When prompted to download the GPG Key for CentOS from the Docker repository, type y for Yes.
sudo yum install docker-ce
Step #4: Start the Docker daemon and enable it to automatically to launch on server boot
Run the command below to start the Docker daemon and enable it to automatically to launch on server boot.
sudo systemctl start docker sudo systemctl enable docker
Verifying Docker Installation
Run the command below to verify that Docker on Linux is running.
sudo systemctl status docker
Similar to the previous tip, you can verify the Docker installation by running the command below to check the version of docker installed on the server.
Here you can see the version of both the docker client and the docker engine. The OS/Arch: property displays Linux since the Docker CE engine is running on a Linux CentOS machine.
Run the command below to display system-wide information regarding the docker installation on the server.
Docker on Windows Containers and Linux
While the method of installation might be different between Windows Server and Linux, the Docker commands are the same for both. You only need to learn one set of tools, no matter which operating system you run. This gives you an advantage of working with a true cross-platform technology for working with and managing containers. But as mentioned in the previous tip, should you require running containers with different operating system platforms, use the appropriate platform for your needs. The container image needs to share the same operating system as the underlying engine, such as Windows Server for Windows Containers and Linux for Linux-based containers.
Now that you have a working Docker environment, you can proceed to start working with containers running SQL Server on either Windows Containers or Linux Containers. You will explore the differences between running SQL Server on a Windows container and a Linux container.
- Read more on the following topics
- Review the previous tips on running SQL Server on Docker
About the author
View all my tips
Article Last Updated: 2019-02-27