Containers: Getting an Image

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:

 docker pull mcr.microsoft.com/mssql/server:2017-latest

Assuming you have Docker installed and running, you should get an image downloaded. Depending on your network bandwidth, this could take as much as 3-5 minutes. It may be as little as around 90 seconds or so. Either way, you now have what you need to run a container with SQL Server 2017.

Now, what if you want to muck about with SQL Server 2019 CTP? Simple, just change the pull command:

docker pull mcr.microsoft.com/mssql/server:2019-CTP2.5-ubuntu

This is getting very specific in the image being pulled. Unlike last time, where we just specified the latest image, this time we’re asking for a particular release and a particular OS.

For a complete listing of the images that Microsoft has published through the Docker Hub, go here.

You can get a list of the images that you’ve pulled or created locally:

docker images

That will show you everything you need. If there’s an image you don’t want around, you can get rid of it. Just run this

docker rmi <IMAGE ID>

and, if necessary

docker rmi <IMAGE ID> -f

If you need help with any of the docker commands, do this:

docker --help
docker rmi --help
docker pull --help

Conclusion

We’re just getting started. This post shows you how to get an image down to your machine so that you can create containers from it using ‘docker pull’. Tomorrow, I’ll show you a couple of ways to create a SQL Server container.


I have several upcoming all day seminars. One is on Query Tuning and the others are on DevOps. Please check the links for details:

SQLSaturday Columbus Precon, June 7 2019, Columbus OH
SQLSaturday Indianapolis Precon, Friday August 16th, 2019. Click here now to register.
SQLSaturday Oslos Precon, Friday August 30th, 2019. Click here to register.

5 thoughts on “Containers: Getting an Image

  • Good stuff, Grant. Thanks again for the new series. I have a tip for you and readers, and a typo for you.

    First, there’s a glitch in the rendering of your “docker rmi” commands. They show the html entities for the left bracket before the imageid. Doh! Darn those web editor UI’s.

    As for the tip (and speaking of referencing image ids): as you’re surely experiencing, those image ids (and container ids, and such) can be long and annoying to type. But check this out: you can just type only enough of an id to make it unique among others you may have. So for an image whose id is a55fbf438dfd, if that may be the only image whose name starts with a, you can remove it with just “docker rmi a”. Sweet! (Of course, you can also refer to the image/container name:label.)

    And I’ll add for other readers that the download of that SQL image took about 8 mins at 10m download speed. This slowness can be an annoyance about Docker and images for those who live or work in low bandwidth environments. Hopefully we don’t have to pull updates often! And even that can go faster if the image creator is careful how they implement image updates.

Please let me know what you think about this article or any questions:

This site uses Akismet to reduce spam. Learn how your comment data is processed.