To begin tinkering with SSIS in containers, you first need to install Docker. There are some prerequisites. I will not exhaust the prerequisites here. I strongly suggest you familiarize yourself with the requirements for Docker prior to attempting to install the software.
Since I use a PC (a Lenovo P51S) running Windows 10 Pro, I chose to use Docker for Windows.
I Needed a HyperVisor
I chose to run Docker for Windows with Hyper-V:
One reason I upgraded to Windows 10 was to work with containers. I read posts and articles that stated I could use Docker for Windows with VirtualBox, and I had been using VirtualBox for a long time. When I started using VirtualBox, it was the only HyperVisor that was:
- Free; and
- Supported 64-bit guests.
I decided to switch to Hyper-V, though, and rebuilt my demo and development virtual machines in Hyper-V.
IWOMM; YMMV (It works on my machine; your mileage may vary…) 😉
Choose a Container OS Platform
Once Docker is installed you need to decide whether to work with Linux or Windows containers, but you can switch anytime:
One nice thing about switching is it’s fairly painless, as one may glean from the message that displays when I click “Switch to Linux containers…”:
Docker for Windows with Windows Containers
The cool kids are using Linux containers, especially the cool SQL Server kids. I’ve tinkered a little with SQL Server on Linux. I’m interested in SSIS, though, so I’ve been focusing on running Windows containers in Docker for Windows.
Containers are like lightweight virtual machines. They typically consume less disk space. Containers spin up relatively quickly. A developer can configure a container, persist it in some state, and then turn it off. It’s faster and lighter than working with a VM. There are other benefits that we will get to later in this series.
After installing Docker, your next step is pulling an image.
Pulling an Image
I can hear you thinking, “Umm, Andy… what’s an image?” I’m glad you asked. From the Docker Glossary:
An Image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime. An image typically contains a union of layered filesystems stacked on top of each other. An image does not have state and it never changes.
I can now hear you thinking, “Umm… what?” I think of an image as a pre-configured container. What’s configured in the pre-configuration? Well, the operating system and other software I may want to use.
For example, the hello-world image is relatively small and will test your installation of docker. In the animated gif below, I show how I:
- Search for images named “hello-world”
- Locate the name of an image labeled “Official” and named “hello-world”
- Pull the “hello-world” image (sped up – my internet is not that fast out here in Farmville…)
- Re-pull the “hello-world” image to show how things look when the image is up to date.
- Run the image
As stated earlier, the hello-world image is a test.
Searching, Pulling, and Starting a Windows Container with SQL Server Installed
To search for, pull, and start a Windows container with SQL Server installed and configured, execute the following Docker commands:
- docker search mssql
- docker pull microsoft/mssql-server-windows-developer
- docker run -d -p 1433:1433 -e sa_password=$up3r$3cr3t -e ACCEPT_EULA=Y –name mySqlServerContainer microsoft/mssql-server-windows-developer
If all goes well, you will see the container id – a hexadecimal number such as:
Command Line Switches
#3 above has a lot of switches on that command line. Here’s what they mean:
- -d == detach, which tells docker to run the container in the background and print the container id
- -p == publish list, which publishes a container’s port(s) to the host
- I use -p to map the container’s port 1433 (SQL Server uses port 1433) to my laptop’s port 1433
- -e == env list, which sets a container’s environment variable(s) to a value (or values).
- I use -e to set the sa_password and ACCEPT_EULA environment variables
- –name == assigns a name to the container
- The final argument is the name of the image
By the way, you can get help on any command in docker by typing docker <command> — help. To complete the list above, I typed:
Interacting with Your Newly-Started Container
If you saw that long hex number, your SQL Server Windows container started. It’s a brand new container – it still has that new container smell.
There are a few ways to interact with this container. Let’s look at one, PowerShell.
Connect to PowerShell in mySqlServerContainer using the following command:
Once connected, you can use PowerShell to execute all sorts of commands, such as:
Cool? I think so too.
I’m going to stop here because this post is long enough and this is enough to get you started using SQL Server in a Windows container. That was my goal today.
In my next post – SSIS, Docker, and Windows Containers, Part 1 – Why? – I explain why this is important (to me, at least).