Docker

Install SQL server on Linux CentOS Redhat create multiple Docker in laptop using VMware Workstation – Part 3

Advertisements

What is Docker container https://www.docker.com/resources/what-container

In simple container is an image or package that will have binaries, configurations etc of the application to run on. Example – In a single OS you can run multiple containers, like CentOS SQL 2017 and 2019 version etc. It is very easy to install, once the image pulled and stored locally, creating SQL server is in a seconds, the advantage is you can create your own images based on the organization standards and store it in Docker HUB. Docker is a container engine developed by Docker to run a containers.

Being SQL server database administrator, mostly we will not worked on Linux platform, I have supported Oracle couple of years and have knowledge of Linux platform.

Following is the 6 steps we are going to test and do ourselves in laptop.

  1. Install VMware workstation and CentOS
  2. Install SQL server on Linux CentOS
  3. Create and install multiple Docker SQL server
  4. Create volumes with persist data for SQL server database files
  5. Customize base SQL server image with Docker file

Creating customized SQL container based the organization standard and push to Docker hub.

Create multiple container from Docker file template by using custom SQL server images.

Create multiple SQL server containers creation by using Docker compose with YML script.

  1. Backup and restore SQL server databases from Linux to windows

 

  1. Create volumes with persist data for SQL server database files

The other problem we are having when we delete the Docker container the configuration and data will also get deleted, including database files.

We can create a Docker volume, mount it on the container and use it to store the database files in the volume. If the container is deleted, the database files are kept in the volume.

Test:

Create a database called dba_test

–remove the container and create it using the –mount, your database will be available

docker rm sql-linux_CE02 -f –remove the container

You can mount this database into new container.

This is the benefit of SQL persist data using mount option. Sometimes, we can use to apply patch by stopping the old container and mount the volume to new container by pulling new image with latest CU/SP.

 

#Persisting Data with Containers

docker volume create sql_data
docker volume inspect sql_data

docker run -e 'MSSQL_AGENT_ENABLED=True' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=G0d$peed' -p 1534:1433 --mount source=sql_data,target=/var/opt/mssql --name sql-linux_CE01_Prest -d -h computer-3.broadband mcr.microsoft.com/mssql/server:2019-latest


============
#create a database called dba_test

# remove the cantainer and create it using the --mount, your database will be avaiable, even container get deleted

docker ps -a
docker start <CONTAINER ID>

docker rm sql-linux_CE01_Prest -f # remove the cantainer

# Remove the container and mount to new sql-linux_CE01_Prest_new
docker run -e 'MSSQL_AGENT_ENABLED=True' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=G0d$peed' -p 1534:1433 --mount source=sql_data,target=/var/opt/mssql --name sql-linux_CE01_Prest_new -d -h computer-3.broadband mcr.microsoft.com/mssql/server:2019-latest

# stop the container sql-linux_CE01_Prest_new_1 and mount the valoume to another container
docker run -e 'MSSQL_AGENT_ENABLED=True' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=G0d$peed' -p 1535:1433 --mount source=sql_data,target=/var/opt/mssql --name sql-linux_CE01_Prest_new_1 -d -h computer-3.broadband mcr.microsoft.com/mssql/server:2019-latest



 

I’m currently working as a SQL server DBA in one of the top MNC. I’m passionate about SQL Server And I’m specialized in Administration and Performance tuning. I’m an active member of SQL server Central and MSDN forum. I also write articles in SQL server Central. For more Click here

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + 1 =