Docker is an operating-system level virtualization technology that allows you to isolate applications in so-called containers without the overhead of conventional virtual machines. In this post, you'll learn how to install Docker on Windows and run your first containers.

Josh Rickard

Josh's primary focus is in Windows security and PowerShell automation. He is a GIAC Certified Windows Security Administrator (GCWN) and GIAC Certified Forensic Analyst (GCFA). You can reach Josh at MSAdministrator.com or on Twitter at @MS_dministrator.

Docker allows developers building a specific functionality (and all of its dependencies) into a small reproducible environment. This has evolved over time by enabling the ability to create small microservices that do one thing and do it well. I like to think of containers as a Windows Service installed without the need for the entire operating system.

Docker is typically associated with Linux, Unix, and macOS, but recently Microsoft has joined the containerization game as well. Docker started on Windows 10 Enterprise, and most recently moved to Windows Server 2016. Understanding containerization is becoming a necessity for system administrators.

Instead of having a whole operating system, you can containerize a small service instead

Instead of having a whole operating system, you can containerize a small service instead

When you enable containers on a Windows system, you have two container types available. The first is the traditional version of Docker you will find on Linux and macOS. The second version is a specific Windows Container version of Docker. They are both similar, although they operate slightly differently.

Installing Docker ^

To enable Docker on Windows, you first need to make sure you meet the minimum requirements. Once you are sure you have met these requirements, you can run the following code snippet to install the latest stable release of Docker for Windows:

If you run into any issues, please see the Docker FAQ here. To start Docker, go to your Start menu and select Docker for Windows:

Go to your Start menu and find Docker for Windows

Go to your Start menu and find Docker for Windows

Next, open up a cmd.exe or powershell.exe (or pwsh.exe) console and type the following:

This displays the Docker version you have just installed:

Run docker v to return the current version of Docker

Run docker v to return the current version of Docker

If things didn't go as planned, please view the official Docker documentation here.

Running a Docker container ^

Run the following command from your PowerShell console:

To visualize what this is doing, imagine you have a repository of "base images" or "minimum requirements" needed for your Docker container to run. This command is running the hello-world image available to the public on the Docker Hub.

Running the docker hello world image

Running the docker hello world image

There are quite a few commands/parameters available when using Docker. But the basic commands you should understand are: docker pull, docker run, docker stop, docker images, docker ps, and docker rm.

The docker pull command will simply download the image from Docker Hub while docker run will pull the image and run it for you after it has completed downloading.

You can identify any currently running Docker containers by using docker ps.

Running docker ps after docker run hello world shows no currently running containers

Running docker ps after docker run hello world shows no currently running containers

To identify all Docker containers on your system, running or not, use the -a parameter (docker ps -a).

Running docker ps a shows all containers running or not

Running docker ps a shows all containers running or not

In the above screenshot, I ran the hello-world container twice, purely as an example. As you can see, each time I ran the hello-world container, it generated a unique Container ID and unique Names (which can be pretty funny sometimes). If one of these containers were running, I would simply use the following command to stop one of them:

To remove this specific container, you can run a similar command:

If you happen to have any running Docker containers, and you would like to stop them, then run docker stop {container id}.

To stop a container, remove it, and run it again, we would do something like this:

You can also view all currently installed/downloaded images on your machine by running the following command:

Viewing all installed Docker images on your system

Docker has some basic terminology you should be familiar with. We have already discussed images, but you should be aware of these terms as well:

  • Containers: Containers are what we use to run our application or service. Containers contain one or more images that make them up.
  • Daemon: Docker daemons are responsible for building, managing, running, and distributing our containers on a host system.
  • Docker client: The Docker client refers to the CLI (command-line interface) used to interact with Docker images, containers, daemons, etc.
  • Docker store: The Docker store (or Docker Hub) contains prebuilt images created (and maintained) by companies and individuals alike.

When we build Docker containers, it is typical (unless your company has a policy against it) to use Docker images from the Docker store (Docker Hub). We use these images to build Docker containers, and we do that by using a special file called a Dockerfile (no extension).

In the next part of the series, I will go further into detail on what a Dockerfile is and how it can benefit us.

Win the monthly 4sysops member prize for IT pros

Share
4+

Users who have LIKED this post:

  • avatar
  • avatar

Articles in series

Docker on Windows

  1. Install Docker and run containers on Windows
  2. Create a Docker container on Windows with a Dockerfile
0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

CONTACT US

Please ask IT administration questions in the forum. Any other messages are welcome.

Sending
© 4sysops 2006 - 2018

Log in with your credentials

or    

Forgot your details?

Create Account