SQL Server Containers Are Boring

Containers
Not really, but sort of. The beauty of containers, at least in a dev/test environment, is the ability to spin them up while you need them and then throw them away when you're done. Containers give you a bunch of functionality not otherwise available through a VM. However, once you've spun up a container, they're so dull. Why Are Containers Boring Grant? I'm so glad you asked. Last week I was presenting at SQLIntersection (great show, you should consider attending). I was talking about Query Store in SQL Server 2019. One person in the audience asked, "Can Query Store run inside a container?" I responded, "Great question, let's check." I then switched over to VS code to show this: [crayon-5d0a6e7a786c2145216939/] Yeah, I had been running all the examples in a…
Read More

Containers: More on Volumes

Containers
In my last post I showed how you can create a volume with your container. I then showed a few things you can with a container using a volume. I want to explore volumes just a little bit more. Locate Your Volume To have a little more fun with volumes, first, let's share a drive. You do this in the Settings in Docker Desktop (assuming that's what you're using): While this should just work, it didn't for me until I restarted Docker. So you may need to do that. Go to the drive and create a directory. I'm putting one in at C:\Docker\SQL. Once I've done that, let's create a new container: [crayon-5d0a6e7a7c908721772060/] Note, I'm using C:\Docker\SQL in the -v volume command and I'm telling it to map to /sql…
Read More

Containers: Create a Custom Container

Containers
Creating a custom container is where things get truly exciting. There's actually a ton of work and knowledge around this. To start with, I'm going to keep it simple. I'm going to create a container with a database & some data and a couple of general customizations. From that, we'll create our own container. To understand why I've got a series on containers, read here. Setting Up a Custom Container To start with, I'm going to spin up a container with nothing fancy: [crayon-5d0a6e7a7d99e159349744/] With this running, let's connect up and make some changes: [crayon-5d0a6e7a7d9b0011532548/] With that in place, let's shut down the container and create an image: [crayon-5d0a6e7a7d9b6311137151/] That's it. Now it's time to test it. Consuming a Custom Container Now, it's just a question of treating it like…
Read More

Containers: Working With Volumes

Containers
In the previous two posts on containers I showed how use Docker commands to get an image and create a container. This time, we're going to create a container again, but, we're also going to create a volume so we can do some fun stuff. For an understanding of why I'm doing a series of blog posts on containers, read here. Docker Volumes You can create a container with a volume, or local, persistent storage. The usage is really simple: [crayon-5d0a6e7a81b93245596624/] This will create and kick off a new container based on SQL Server 2017. Nothing to it really. If you get the IP address for the machine, you can connect to it through Azure Data Studio or SQL Server Management Studio. Just be clear, I used a port, 1450,…
Read More

Containers: Creating a Container

Containers
In yesterday's blog post we pulled SQL Server images in preparation for today's blog post where we create containers from those images. If you haven't already, get Docker installed and follow the instructions here to get at least one image on your machine. If you're interested in why I'm talking about containers all week, read this. I'm using all PowerShell commands to control Docker. Docker Run You can use 'docker create' to create an image and then start it up. However, we can just get started running a container from one of the images we downloaded yesterday. We can just simultaneously create and start the container using 'docker run': [crayon-5d0a6e7a836d3816274106/] Let's break this down a bit so you know what you just did. The two '-e' statements are setting environment…
Read More

Containers: Getting an Image

Containers
I'm working with Docker running on Windows or Linux. There are other ways to do this, but Docker seems to be a pretty strong standard. I'll leave it to you to get Docker installed on your system. Go here to get the appropriate installation. I explain why I'm learning Docker and containers here if you're interested. Docker Pull The first command you have to learn is 'docker pull'. You then have to supply something for it to pull, an image that will be used to create your containers. I'm using Powershell for the commands I'm posting this week. Here's how you get an image with SQL Server 2017: [crayon-5d0a6e7a85c82757414022/] Assuming you have Docker installed and running, you should get an image downloaded. Depending on your network bandwidth, this could take…
Read More