Setting up a SQL Server Development Environment with Docker Containers - Part 2 - The Basics

Published on Thursday, April 16, 2020

This is continued from Part 1 - Introduction

The Basics

The first step in learning any new technology is naturally to Google/Bing furiously and begin reading everything you can. I began my journey at the Docker website where I installed Docker Desktop and worked through some of the samples

Docker 101 Link

Basic Docker Commands

Here are some basic commands you should learn. I'll add more details and links to the documentation below.

View Running Containers. The -a or --all tag will view all containers, whether they're running or not.

docker ps (-a)

Pull a Container Image

docker pull ImageUrl

Start an existing Container

docker start ContainerName

Stop a Container

docker stop ContainerName

Run a new container from a container image

docker run ImageName

Build a new container image

docker build (-t) .

These last two remove data so be careful!

Remove a container

docker rm ContainerName

Remove an image

docker image rm ImageName

Remove all ununsed containers, networks, and images (both dangling and unreferenced)

docker system prune

During my experiments I had plenty of times where I created a new container that immediately exited. You'll need to develop the ability to troubleshoot your unexpected container exits.

To find an exit code for a stopped container, use:

docker inspect 

From there, you'll need to use that exit code to gather more information.

Here's a list of some Common Docker Exit Codes.

Continue this series in Part 3 - Building Your First SQL Server Docker Container.