{"id":78227,"date":"2018-04-16T14:49:43","date_gmt":"2018-04-16T14:49:43","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=78227"},"modified":"2021-08-24T13:39:19","modified_gmt":"2021-08-24T13:39:19","slug":"provisioning-sql-server-instances-docker","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/devops\/containers-and-virtualization\/provisioning-sql-server-instances-docker\/","title":{"rendered":"Provisioning SQL Server Instances with Docker"},"content":{"rendered":"<p>We DBAs tend to make a meal out of provisioning SQL Server instances. We just aren\u2019t used to the idea of being able to get a SQL Server instance up and running without a lengthy setup and the installation of all those prerequisites. However, our Ops friends, especially the Linux people, just smile and shake their heads when they see us staring at the SQL Server installation screens. They save a lot of time by using Docker. We can do the same thing, using PowerShell to script the process.<\/p>\n<p>Why is it now so important to be able to provision instances so quickly? It is because it makes for a more reliable release of software if the tests and experiments that are done in dev, test and CI\/CD systems are maintained in separate isolated instances to be sure of avoiding the consequences of something breaking an instance. With Docker, you can start as many fresh clean instances of SQL Server on a host as you need just by running <strong>docker run<\/strong>. When you are finished with them, you can tear them back down again without any messy residuals. This is where it is most useful to have SQL Server in its own container.<\/p>\n<p>You can run SQL Server in a Linux environment using a Linux Docker, using Docker Enterprise Edition to run a supported version of SQL Server in Linux in containers. You can also run SQL Server in Windows Docker on Windows 10 or Windows server 2016. It\u2019s also possible to run SQL Server in Docker on a Mac!<\/p>\n<h2>Docker Overview<\/h2>\n<p>So, what is Docker? Docker is an open-source platform, written in Go, which is a high-performance language from Google. Go gives Docker extreme portability because the compiled application doesn\u2019t rely on external dependencies.<\/p>\n<p>Docker allows administration in isolated systems. Docker is not a virtualization engine, because it uses common Kernel Libraries (host and container) resources rather than having its own isolated resources. In virtualization, we have the full Operating system, and in Docker we have only the Kernel Libraries \u2013 in Windows Nano Server<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"948\" height=\"696\" class=\"wp-image-78228\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/resultado-de-imagem-para-o-que-e-docker.jpeg\" alt=\"Resultado de imagem para o que \u00e9 docker\" \/><\/p>\n<p>Because most of us SQL Server DBAs are more comfortable with Windows, we will want to take advantage of the fact that we can run SQL Server in a Docker container on Windows Server and Windows 10. As it is Windows, we can script it all out in PowerShell. Here, I\u2019ll be showing how to do it using an Azure Virtual Machine running Windows Server 2016, PowerShell, and Docker. The script will work without the virtual machine if you prefer to do it that way.<\/p>\n<p>Before you start, create your machine, virtual or not, install Windows Server 2016 and then follow the PowerShell code step by step in Admin mode (\u2018Run as Adminstrator\u2019)<\/p>\n<h2>Setting up Docker<\/h2>\n<p>At the time of this writing, Docker have made two versions of Docker for Windows available. For Windows 10, use the <a href=\"https:\/\/docs.docker.com\/install\/windows\/docker-ee\/\">Docker Community Edition<\/a>. Since this article is about using Windows Server 2016, you will install the <a href=\"https:\/\/docs.docker.com\/install\/windows\/docker-ee\/\">Docker Enterprise Edition for Windows Server<\/a> if you care to follow along.<\/p>\n<p>Start up a PowerShell command window running as an administrator and run the following commands to download and install the latest version of Docker:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Install-Module DockerMsftProvider -Force\r\nInstall-Package Docker -ProviderName DockerMsftProvider -Force<\/pre>\n<p>If prompted to install any prerequisites such as NuGet, type in Y and restart once the installation is complete.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"860\" height=\"320\" class=\"wp-image-78229\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-127.png\" \/><\/p>\n<h2>Testing your Docker Install<\/h2>\n<p>Check the Docker version by running this command:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker version<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"429\" height=\"224\" class=\"wp-image-78230\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-128.png\" \/><\/p>\n<p>Then you can test out Docker by downloading a container that they have for that purpose called <em>hello-world:nanoserver.<\/em><\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker container run hello-world:nanoserver<\/pre>\n<p>Docker checks first to see whether the image is already there. If not, it downloads it and runs it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-78231\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-129.png\" width=\"677\" height=\"388\" \/><\/p>\n<h2>Checking the Microsoft Repository and Download SQL Server<\/h2>\n<p>Now that Docker is successfully installed and running, you can begin creating a SQL Server container. Check the Microsoft repository at Docker:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">docker search microsoft<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"844\" height=\"343\" class=\"wp-image-78232\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-130.png\" \/><\/p>\n<p>Download the SQL Server repository locally. These are big files.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">docker pull microsoft\/mssql-server-windows-developer <\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"881\" height=\"194\" class=\"wp-image-78233\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-131.png\" \/><\/p>\n<p>The latest mssql images, for example, are over 12 GB in size. Even \u2018Hello World\u2019 takes over a GB. It may take quite a few minutes to download the image.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"618\" height=\"238\" class=\"wp-image-78234\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-132.png\" \/><\/p>\n<p>Check the local repository images that were downloaded:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker images <\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1142\" height=\"200\" class=\"wp-image-78235\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-133.png\" \/><\/p>\n<h2>Spin up a SQL Server Instance<\/h2>\n<p>Once the image has been downloaded, it\u2019s time to spin up the SQL Server instance. From an elevated PowerShell session, you can use the <strong>docker run<\/strong> command to set the required properties and run the instance. Here is an explanation of the parameters:<\/p>\n<ul>\n<li><strong>&#8212;&#8212;name <\/strong>(provide a friendly name for the container)<\/li>\n<li><strong>&#8212;d<\/strong> (executes the container in background)<\/li>\n<li><strong>&#8212;p<\/strong> (port mapping)\n<ul>\n<li><strong>port:port (14331:1433)<\/strong> \u2013 Here we are mapping the port of the container (14331) with the 1433 port to SQL. We are doing that because we will create 2 SQL Server containers. If you will be connecting to SQL from the OS host or only one container you can map as 1433:1433 as each container has its own IP. As we are connecting externally also (from my physical machine too) there is only one IP (the OS host VM). What will differentiate the container is the port.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8212;e<\/strong> (creates environment variables under the container execution runtime)\n<ul>\n<li><strong>sa_password<\/strong> ( assign the SQL Server SA password \u2013 s@12345)<\/li>\n<li><strong>ACCEPT_EULA<\/strong> (pass Y)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Run this command and modify the password if you wish.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker run --name sql01 -d -p 14333:1433 -e sa_password=s@12345 -e ACCEPT_EULA=Y microsoft\/mssql-server-windows-developer <\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"841\" height=\"52\" class=\"wp-image-78236\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-134.png\" \/><\/p>\n<p>Once that is complete, check which containers are executing.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">docker ps<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"841\" height=\"78\" class=\"wp-image-78237\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-135.png\" \/><\/p>\n<h2>Connecting to the SQL Server<\/h2>\n<p>To connect to SQL Server from inside the VM, you need to know the IP of the container. <strong>Inspect &lt;container name&gt;<\/strong> will return a lot of information. You need to find the correct node in the JSON document and save it in a variable<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">docker inspect sql01  <\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"842\" height=\"218\" class=\"wp-image-78238\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-136.png\" \/><\/p>\n<p>As this is returning a large JSON document, you can do better than to search through it. Instead, you can access the value you require with this script.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">$Container_1 = docker inspect sql01 | \r\nConvertFrom-Json | \r\nselect -ExpandProperty SyncRoot | \r\nselect -expand netWorkSettings | \r\nselect -ExpandProperty Networks | \r\nSelect -ExpandProperty nat | \r\nSelect IPAddress \r\n$Container_1<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"495\" height=\"157\" class=\"wp-image-78239\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-137.png\" \/><\/p>\n<div class=\"note\">\n<p>NOTE: Each time your container is started, be that a host server reboot or a restart of the container, the IP address can change<\/p>\n<\/div>\n<p>Now you can connect to SQL Server using SSMS from within the virtual machine using the container\u2019s internal IP. Substitute your own IP and use sa with the password you provided when spinning up the instance. Of course, you will need SSMS installed on the VM.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"482\" height=\"321\" class=\"wp-image-78240\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-138.png\" \/><\/p>\n<p>And we have confirmed that it\u2019s working!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1127\" height=\"406\" class=\"wp-image-78241\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-139.png\" \/><\/p>\n<h2>Accessing the Container Outside the VM<\/h2>\n<p>To access the container externally, you will need to open the firewall port you used when creating the container. This example used port 14333.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"845\" height=\"73\" class=\"wp-image-78242\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-140.png\" \/><\/p>\n<p>If you are working in an Azure VM, you must also add the port to the Network Interface in the Azure Portal on the Networking page of your VM. Set the port up as a Custom port in both the Inbound and Outbound security rules.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"259\" height=\"371\" class=\"wp-image-78243\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-141.png\" \/><\/p>\n<p>You will also need to determine the external IP of the VM. If running in Azure, you can find the IP on the Networking page of the VM. If you are following along using another method, just determine the IP you use to connect to your VM.<\/p>\n<p>Now you can connect to SQL Server, passing the container port to differentiate between the containers. In this example, 13.86.80.154,14333.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"484\" height=\"322\" class=\"wp-image-78244\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-142.png\" \/><\/p>\n<h2>Managing the Container<\/h2>\n<p>Whenever you restart the VM, you will find that the containers are no longer running. If you run the <strong>docker ps<\/strong> command used earlier to view the running containers, you\u2019ll see this after a restart.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker ps<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"762\" height=\"66\" class=\"wp-image-78245\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-143.png\" \/><\/p>\n<p>The containers are not gone, they are just not running. You can add the <strong>-a<\/strong> switch to see all containers, regardless of status.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker ps -a<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"841\" height=\"130\" class=\"wp-image-78246\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-144.png\" \/><\/p>\n<p>To start a container, use the <strong>docker container start<\/strong> command.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">docker container start sql01<\/pre>\n<p>You can also stop, restart, remove, and more with the <a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/container\/\">Docker container<\/a> command. For example, this script stops the SQL Server instance and then removes it.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker container stop sql01\r\nDocker container rm sql01<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"839\" height=\"139\" class=\"wp-image-78247\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-145.png\" \/><\/p>\n<p>The ability to quickly create and tear down instances is probably the biggest advantage of using Docker to host SQL Server.<\/p>\n<p>If you removed sql01 by following the last example, run this command to create it once more so you can follow along with the rest of the article.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker run \u2013-name sql01 -d -p 14333:1433 -e sa_password=s@12345 -e ACCEPT_EULA=Y microsoft\/mssql-server-windows-developer <\/pre>\n<p>If your container must run automatically after a restart of the host, you can add the <a href=\"https:\/\/docs.docker.com\/config\/containers\/start-containers-automatically\/#use-a-restart-policy\">restart <\/a>flag to the command.<\/p>\n<h2>Managing the SQL Server Instance<\/h2>\n<p>You will find that managing the SQL Server instance is similar to managing a traditional instance, but since the container runs in its own space, there are a few differences. Since the container lives in its own space, it cannot see outside that space. For example, it cannot directly backup to a folder outside the container. To demonstrate, first list the directory contents of the C:\\ drive on the VM.<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Dir c:\\<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"506\" height=\"238\" class=\"wp-image-78248\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-146.png\" \/><\/p>\n<p>You will probably see a different set of folders than what I see on my VM. Now, connect a PowerShell session directly to the container by running this command:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">Docker exec -it sql01 PowerShell <\/pre>\n<p>The PowerShell window will change, and you will see a new session running from inside the container. Run the <strong>ls<\/strong> or <strong>dir<\/strong> command to see the folder contents.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"504\" height=\"207\" class=\"wp-image-78249\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-147.png\" \/><\/p>\n<p>The folder list is very different than that of the VM since you are viewing inside the container.<\/p>\n<h2>Copy a Backup File to the Container<\/h2>\n<p>To backup and restore databases hosted by the instance running in a Docker container, you will need to provide a way to move files between the instance and the host. Follow these instructions to learn one way to do this.<\/p>\n<ol>\n<li>On the host machine, create a <em>C:\\Temp<\/em> folder if one does not exist.<\/li>\n<li>Download the <a href=\"https:\/\/github.com\/Microsoft\/sql-server-samples\/releases\/download\/wide-world-importers-v1.0\/WideWorldImporters-Full.bak\">WideWorldImporters_Full.bak<\/a> file to the <em>C:\\Temp<\/em> folder.<\/li>\n<li>Make sure you have a PowerShell session running that is connected to the container.<\/li>\n<li>Create a <em>C:\\Temp\\Backup<\/em> folder in the container\n<pre class=\"lang:ps theme:powershell-ise\">Md Temp\r\nCD Temp\r\nMD Backup<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"535\" height=\"273\" class=\"wp-image-78250\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-148.png\" \/><\/p>\n<\/li>\n<li>You can then switch back to the host in the PowerShell Session using <strong>Exit<\/strong>.\n<pre class=\"lang:ps theme:powershell-ise\">Exit<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"180\" height=\"43\" class=\"wp-image-78251\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-149.png\" \/><\/p>\n<\/li>\n<li>Now that the directory is created, you can use docker to copy the <em>.bak<\/em> file to the backup folder in the container using the <strong>docker cp<\/strong> command. Note that the directory and file names are case sensitive.\n<pre class=\"lang:ps theme:powershell-ise\">Docker cp C:\\Temp\\WideWorldImporters-Full.bak sql01:C:\\Temp\\Backup<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"62\" class=\"wp-image-78252\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-150.png\" \/><\/p>\n<\/li>\n<li>Connect back to the container.\n<pre class=\"lang:ps theme:powershell-ise\">docker exec -it sql01 PowerShell<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"679\" height=\"58\" class=\"wp-image-78253\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-151.png\" \/><\/p>\n<\/li>\n<li>In the new PowerShell session, look for the file.\n<pre class=\"lang:ps theme:powershell-ise\">Dir temp\\backup<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"689\" height=\"215\" class=\"wp-image-78254\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-152.png\" \/><\/p>\n<\/li>\n<\/ol>\n<h2>Restoring the Database<\/h2>\n<p>Now that the file is in a place that the SQL Server instance can see it, you should connect with SSMS and do a restore as usual. If you wish to connect from within the VM, you will probably need to determine the IP address again using the script from the earlier section within a PowerShell session running in the host:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">$Container_2 = docker inspect sql01 | \r\nConvertFrom-Json | \r\nselect -ExpandProperty SyncRoot | \r\nselect -expand netWorkSettings | \r\nselect -ExpandProperty Networks | \r\nSelect -ExpandProperty nat | \r\nSelect IPAddress\r\n$Container_2<\/pre>\n<p>The restore can be done as usual from within SSMS:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"916\" height=\"497\" class=\"wp-image-78255\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-153.png\" \/><\/p>\n<h2>Creating a Backup Volume<\/h2>\n<p>Instead of backing up to a folder inside the container and then copying the file to the host, another way to manage backups is to mount a volume to the container that can be accessed by both the host and the container. When doing this, you must create a new container.<\/p>\n<ol>\n<li>Connect to PowerShell running in the VM and run this command which creates a new Docker volume called SQLBackups.\n<pre class=\"lang:ps theme:powershell-ise\">Docker volume create \u2013name SQLBackups<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"481\" height=\"64\" class=\"wp-image-78256\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-154.png\" \/><\/p>\n<\/li>\n<li>Find the location of the new volume. By default, volumes are created at the hidden location C:\\ProgramData\\docker\\volumes\n<p><img loading=\"lazy\" decoding=\"async\" width=\"862\" height=\"170\" class=\"wp-image-78257\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-155.png\" \/><\/p>\n<\/li>\n<li>Now you will create a new container called sql02 that will be able to use the new volume. The command uses the <strong>v<\/strong> switch to map the volume on the host to the container.\n<pre class=\"lang:ps theme:powershell-ise\">Docker run --name sql02 -d -p 14334:1433 -v c:\\programdata\\docker\\volumes\\sqlbackups:c:\\backups -e sa_password=s@12345 -e ACCEPT_EULA=Y microsoft\/mssql-server-windows-developer<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"845\" height=\"182\" class=\"wp-image-78258\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-156.png\" \/><\/p>\n<\/li>\n<li>Copy the <em>WorldWideImporters<\/em> backup file to the new volume.\n<pre class=\"lang:ps theme:powershell-ise\">copy c:\\temp\\WideWorldImporters-Full.bak C:\\ProgramData\\docker\\volumes\\sqlbackups<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"742\" height=\"48\" class=\"wp-image-78259\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-157.png\" \/><\/p>\n<\/li>\n<li>Connect to the new container with PowerShell.\n<pre class=\"lang:ps theme:powershell-ise\">docker exec -it sql02 PowerShell<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"488\" height=\"65\" class=\"wp-image-78260\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-158.png\" \/><\/p>\n<\/li>\n<li>Look for the backup file within the container.\n<pre class=\"lang:ps theme:powershell-ise\">Dir backups<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"147\" class=\"wp-image-78261\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/04\/word-image-159.png\" \/><\/p>\n<p>Now there is a folder that both the host and container can see. The SQL Server instance can backup directly to the backups folder. If you actually wanted to use one of these mounted volumes for the database files (<em>mdf, ldf, ndf<\/em>) you could as well.<\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>When Microsoft announced support for SQL Server on Linux and Docker, it was obvious that the world of the DBA was changing. This was smart on Microsoft\u2019s part as it can possibly get SQL Server in shops that wouldn\u2019t have considered it in the past.<\/p>\n<p>This article showed how to get Docker running on a server and how to create a container running SQL Server. It then discussed how to work with the container and with the instance. Be sure to take a look at the Docker documentation to get more ideas on how to better manage SQL Server running on Docker.<\/p>\n<p>I would like to thank my good friend Anderson Alves de Souza for the initial research.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With SQL Server 2017, Microsoft announced the exciting news that SQL Server would now run in Docker containers. Laerte Junior provides a guide to get started creating SQL Server instances in Docker.&hellip;<\/p>\n","protected":false},"author":221715,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143513,143527],"tags":[95506],"coauthors":[6819],"class_list":["post-78227","post","type-post","status-publish","format-standard","hentry","category-containers-and-virtualization","category-database-administration-sql-server","tag-automate"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/78227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/221715"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=78227"}],"version-history":[{"count":12,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/78227\/revisions"}],"predecessor-version":[{"id":78264,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/78227\/revisions\/78264"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=78227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=78227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=78227"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=78227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}