Page 14 - MSDN Magazine, June 2019
P. 14

Exploring the Containers
Created by docker-compose
Now let’s see what’s going on with Docker. I’ll do that at the com­ mand line, although the Docker extension for Visual Studio Code is another cool option for achieving this.
First, I’ll list the images with the command docker images. If you’re new to using the Docker CLI, you may prefer to use the more explicit command docker image ls. As you can see in Figure 3, this shows that the mssql image is now on my machine and that a new version of my dataapidocker image was created, as well.
Next, I’ll check out the containers with docker ps, the shortened equivalent of docker container ls. This output is wide so I’m showing the left half of the screen above the right half in Figure 4.
And, finally, to see the volume that was created, which is now tied to the db container, I can use the docker volume ls command, as shown in Figure 5.
Notice that the names of both containers and the data volume are prefaced with the same text generated by the Visual Studio debug process in combination with the tooling.
Figure 6 Setting Up a Connection to My Containerized Database
Remember that I’ve exposed the database from the container on the host’s port 1433 so I can use tools on my development machine to look at the server that’s inside the db container, along with the databases in the attached volume. I’ll use Azure Data Studio to do this; Figure 6 shows how I defined the connection.
Having your apps encapsulated in Docker images makes it so easy to deploy the apps and all of their dependencies as containers.
With the connection made, I can then interact with the server and my new database. Figure 7 shows the database explorer on
the left, along with a query and results on the right.
Your App’s Containers Are Ready for Action
Having your apps encapsulated in Docker images makes it so easy to deploy the apps and all of their dependencies as containers. But for container newbies and veterans alike, I think that having the tools to develop apps so that they’re already associated with images and orchestration makes leveraging contain­ ers so much more straightforward. And in this series I’ve focused on development and local debugging only. Following Part 2, I published a blog post about deploy­ ing the single­image solution to Azure for testing at bit.ly/2CR40x3. That solution stores its data in Azure SQL Database and I run the test container using Azure Container Instances. I also wrote a blog post about publishing the dataapidocker image from this article to Docker Hub and then hosting the full solution in a Linux virtual machine on Azure, which is another
great way to test your orchestrated containers. You can find that blog post at bit.ly/2VBaN8M. n
Julie lerman is a Microsoft Regional Direc- tor, Microsoft MVP, software team coach and consultant who lives in the hills of Ver- mont. You can find her presenting on data access and other topics at user groups and conferences around the world. She blogs at thedatafarm.com/blog and is the author of “Programming Entity Framework,” as well as a Code First and a DbContext edition, all from O’Reilly Media. Follow her on Twit- ter: @julielerman and see her Pluralsight courses at bit.ly/PS-Julie.
Thanks to the following technical experts for reviewing this article: Elton Stoneman (Docker), Travis Wright (Microsoft)
Data Points
Figure 7 Interacting with the Containerized Database in Azure Data Studio 10 msdn magazine


































































































   12   13   14   15   16