Docker

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

Advertisements

This is follow up series:

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 and install multiple Docker container SQL server

Now we are installing and configuring Docker container for SQL server to run on.

Pull SQL image from Docker hub and create a container.

Create a Docker container with SQL server agent enabled.

Try connect it from SSMS into the container SQL from your laptop using the port you specified in the creation.

  1. Create a test database
  2. Create a test backup job
sudo yum update

sudo yum install yum-utils device-mapper-persistent-data lvm2

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

sudo yum install docker-ce #Install the docker

sudo systemctl start docker

sudo systemctl enable docker

sudo systemctl status docker

docker version

docker info

docker run hello-world #Test the docker installed correctly or not

docker search microsoft | grep sql #get the microsoft binaries from Docker Hub

docker pull mcr.microsoft.com/mssql/server:2019-latest #Pull the image and store it on local

docker images

#https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash
##https://hub.docker.com/_/microsoft-mssql-server ## Microsoft SQL server image version can be found here

#Enable agent while creating a container

docker run -e 'MSSQL_AGENT_ENABLED=True' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=G0d$peed' -p 1533:1433 --name sql-linux_CE01 -d -h computer-3.broadband mcr.microsoft.com/mssql/server:2019-latest

# We can do this from ssms as well

/opt/mssql-tools/bin/sqlcmd -S ip,port -U user name

[root@computer-3 ~]# /opt/mssql-tools/bin/sqlcmd -S 192.168.1.27,1533 -U SA
Password:
1> create databsae dba_test
2> go
Msg 343, Level 15, State 1, Server computer-3, Line 1
Unknown object type 'databsae' used in a CREATE, DROP, or ALTER statement.
1> create database dba_test
2> go
1> exit


#### Check and remove docker, volume, network 
docker ps -a
docker images

docker container ls -a
docker container rm <container id-1> <container id-2> etc

docker start <CONTAINER ID>
docker stop <CONTAINER ID>
docker rm <CONTAINER ID> #-f
docker image rmi <image id>

docker volume ls
docker volume rm <volume name>
docker network ls
docker network rm <network id>

 

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 + = 14