Docker Containers: Getting An Image
I will be working with Docker running on Windows (although sometimes on Linux). Docker appears to be the most popular and has a strong standard. You can go here to get the appropriate Docker installation. If you are unfamiliar with what a container is or why they are used Docker has a great explanation here. Basically, a container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, run-time, system tools, system libraries and settings. Pulling an image basically means downloading all the files needed to run a container. You can think of this as downloading the SQL Server installation files.
Testing Installation
After your installation, you will want to test it. Using PowerShell, I tested my installation using the following:
Test Docker version
- Run
docker --version
and ensure that you have a supported version of Docker: - Run
docker info
(ordocker version
without--
) to view even more details about your Docker installation:
Test Docker installation
- Test that your installation works by running the simple Docker image, hello-world:
- List the
hello-world
image that was downloaded to your machine: - List the
hello-world
container (spawned by the image) which exits after displaying its message. If it were still running, you would not need the--all
option:
Docker Pull
A docker pull
is simply pulling an image or a repository from a registry.
Most of your images will be created on top of a base image from the Docker Hub registry. Pulling an image basically means downloading all the files needed to run a container. You can think of this as downloading the SQL Server installation files.
Docker Hub contains many pre-built images that you can pull
and try without needing to define and configure your own.
To download a particular image, or set of images (i.e., a repository), use docker pull
. Go Here for more in-depth information.
Usage
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
Options
Name, shorthand | Default | Description |
--all-tags , -a | Download all tagged images in the repository | |
--disable-content-trust | true | Skip image verification |
--platform | experimental (daemon)API 1.32+ Set platform if server is multi-platform capable |
Here’s how you get an image with SQL Server 2017:
docker pull mcr.microsoft.com/mssql/server:2017-latest
Now you have a container with SQL Server 2017. If you want more information or SQL Server 2019 (versions update) you can read more on the Docker SQL Server page.
List the most recently created images
You can get a list of the images that you’ve pulled or created locally:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 77af4d6b9913 19 hours ago 1.089 GB
committ latest b6fa739cedf5 19 hours ago 1.089 GB
<none> <none> 78a85c484f71 19 hours ago 1.089 GB
docker latest 30557a29d5ab 20 hours ago 1.089 GB
<none> <none> 5ed6274db6ce 24 hours ago 1.089 GB
postgres 9 746b819f315e 4 days ago 213.4 MB
postgres 9.3 746b819f315e 4 days ago 213.4 MB
postgres 9.3.5 746b819f315e 4 days ago 213.4 MB
postgres latest 746b819f315e 4 days ago 213.4 MB
Let’s not forget our docker help
commands:
docker --help
docker rmi --help
docker pull --help