SQL Server 2017 on Windows Containers – Part 3 (Linux Platform)

In continuation to my previous post about SQL on Windows container, I am going to write about SQL on Windows containers for Linux platform. We can have both Linux and Windows containers on Windows platform. I am going to share the steps, to have SQL on Linux containers.

Step 1 – Enable container  and Hyper-V role on Windows:

image

Step 2  – Download Docker Engine for Windows 10 from https://docs.docker.com/docker-for-windows/install/

clip_image001[7]

Step 3 – Change the mode to Linux containers – right click on the Docker icon in the windows tray:

image

After switching to the Linux Containers, automatically Linux VM is created. If you open Hyper-V manager, you could see:

image

Step 4 –  Pull the Docker image from the Docker hub – https://hub.docker.com/r/microsoft/mssql-server-linux/

Command to be run  –  docker pull microsoft/mssql-server-linux

image

Note – In this case, the image has already been downloaded.Otherwise, it will download the image from the docker hub.

Step 5 – Once the image is downloaded,  run this command to check if the image is downloaded :

Docker images

image

Step 6 – To check how many components have been patched in the image, run this command:

docker history microsoft/mssql-server-linux

image

Step 7 – Spin up the container using this command :

docker run -e “ACCEPT_EULA=Y” -e “MSSQL_SA_PASSWORD=test123@” -e “MSSQL_PID=Developer” –cap-add SYS_PTRACE -p 1401:1433 -d microsoft/mssql-server-linux

To read about the switches used in the above command check this link –  https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker

Step 8 – Check the status of the container – run this command 

Docker ps –a

image

If you see in the picture above, it shows the status and id of the container and status which is up for 31 hours. To confirm if the SQL inside the container is up and running or check the SQL errorlog, run this command:

Docker logs <Container_id>

image

Step 9 – Let’s connect to SQL server intance: This command is to connect from within the container

docker exec –it <Docker ID>/opt/mssql-tools/bin/sqlcmd -S localhost -U SA

image

Step 10 – Let’s connect from SQL Server management Studio from outside the container:

Connect either using IP of the machine hosting containers or the localhost and  port number. Entering port number is must- If you have multiple containers spun then port number will uniquely identify the container:

image

 

Step 11 – Let’s connect inside the container and check the files and folders:

image

just run the top command and you will see the SQL server process running: 

image

HTH!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s