In today’s article, I will talk about Installing Docker And SQL Server 2017 On LinuxVM In Azure.
After the announcement that SQL Server 2017 is running on Docker, I was working on docker and today I will tell you “Installing Docker and SQL Server 2017 on LinuxVM in Azure”. I have a LinuxVM on Microsoft Azure for test run. You can see the features of this machine below.
After connecting to the Linux VM via SSH, what we need to do is update our package list with apt-get update.
1 |
[code] sudo apt-get update [/code] |
After updating the package list, we install the necessary package to be able to install packages over HTTPS.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[code] sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common [/code] |
As the third step, we add the Docker official GPG key.
1 2 3 4 5 |
[code] curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add – [/code] |
We add the Docker repo to our apt repos.
1 2 3 4 5 6 7 8 9 10 11 |
[code] sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" [/code] |
We are updating our package list again to be able to install Docker CE.
1 2 3 4 5 |
[code] sudo apt-get update [/code] |
We run the code below to install the latest version of Docker Ce.
1 2 3 4 5 |
[code] sudo apt-get install docker-ce [/code] |
We have completed the Docker installation on LinuxVM, let’s see our Docker running first.
1 2 3 4 5 |
[code] sudo systemctl status docker [/code] |
Let’s write a simple “Hello World” Text to test docker now.
As you can see, we have successfully completed the docker installation. Now it’s time to install SQL Server 2017 on the docker we installed.
Before starting the SQL Server installation, we need to get the Linux image of SQL Server 2017 from Docker Hub. For this ;
1 2 3 4 5 |
[code] sudo docker pull microsoft/mssql-server-linux:2017-latest [/code] |
Now that we’ve pulled the image of SQL Server 2017, we now need to run the image on docker. For this process ;
1 2 3 4 5 6 7 8 9 |
[code] sudo docker run -e ‘ACCEPT_EULA=Y’ -e ‘SA_PASSWORD=http://www.caglarozenc.com’ \ -p 1433:1433 –name DockerSQL \ -d microsoft/mssql-server-linux:2017-latest [/code] |
The SA password that we will define here must be a complex password, otherwise the sql server service will not start. As you can see, we also defined the installation.
Now let’s list the containers running with the “docker ps” command. If we ran a “docker ps -a” run, we would also see the containers that were running and stopped.
1 2 3 4 5 |
[code] sudo docker ps [/code] |
Yes, as you can see, our docker is running, we also have a container on which we installed sql server 2017 and it has been up for 2 minutes. Finally, let’s access this database server.
sqlcmd can also be used during the connection phase. Let’s give our first connection example via SQLCmd.
1 2 3 4 5 |
[code] sudo docker exec -it DockerSQL /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ‘<a href="http://www.caglarozenc.com/">http://www.caglarozenc.com</a>’ [/code] |
As you can see, SQL Server 2017 is running on docker and we learned the version information. Well, let’s get some server information such as ServerName with SQL Operation Studio.
After installing SQL Operation Studio, we write our server information as below and click connect.
After the connection process is completed, we run the following code block and learn the basic information about the server.
1 2 3 4 5 6 7 |
[code] SELECT @@SERVERNAME, SERVERPROPERTY(‘ComputerNamePhysicalNetBIOS’), SERVERPROPERTY(‘MachineName’), SERVERPROPERTY(‘ServerName’) [/code] |
As you can see, the values returned in the query result return the container ID information to us.
We have come to the end of another article. We will continue our articles on Docker. See you.
Footnote: You can connect not only with SQL Operation Studio, but also with an up-to-date SQL Server Management Studio v17.x.