Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 

Getting Started with Linux Containers for SQL Server - Part 2


By:   |   Last Updated: 2019-02-27   |   Comments   |   Related Tips: 1 | 2 | 3 | 4 | More > Containers

Problem

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.

Solution

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.

  1. Update Linux system packages and install the required dependencies
  2. Add the Docker stable repository to your system
  3. Install the Docker CE engine
  4. 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
Update Linux system packages and install the required dependencies

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
Add the Docker stable repository to your system

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
Install the Docker CE engine

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
Start the Docker daemon and enable it to automatically to launch on server boot

Verifying Docker Installation

Run the command below to verify that Docker on Linux is running.

sudo systemctl status docker
verify that Docker on Linux is running

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.

docker version
Docker Version

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 info
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.

Next Steps


Last Updated: 2019-02-27


next webcast button


next tip button



About the author
MSSQLTips author Edwin Sarmiento Edwin M Sarmiento is a Microsoft SQL Server MVP and Microsoft Certified Master from Ottawa, Canada specializing in high availability, disaster recovery and system infrastructures.

View all my tips




Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 


Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



    



Learn more about SQL Server tools