Becoming familiar with containers and containerized infrastructure will most certainly put you in close contact with Docker and Docker containers. You can run Docker containers on your Windows Server with Hyper-V installed and provide a way to run your containerized workloads effectively. This post will look at working with Docker containers in Windows.
Table of Contents
- Windows Docker containers tools
- Docker command line
- Docker pull
- Docker run
- Docker ps
- Docker inspect
- Docker commit, save, load, export, and import
- Windows Admin Center
- Wrapping Up
Windows Docker containers tools
Before we talk about working with Docker containers in Windows, it is good to understand the tools we can use to work with containers in Windows. There are two ways we will look at working with Windows Server containers. These include:
- Docker command line
- Windows Admin Center
The Docker command line is a great way to interact with your containers running in Windows, as it arguably provides the most robust way to work with your containers. With the Docker command line tools, you can start, stop, remove, export, import, inspect, and configure the containers running on your Windows container host.
However, there is another tool Microsoft is heavily working on. That is the Windows Admin Center (WAC) tool. It is now the de facto standard for managing and configuring Windows Server, taking the place of the traditional Server Manager. In addition, Microsoft has continuously improved the container support in Windows Admin Center and continues to introduce features and capabilities with container management.
Docker command line
The Docker command line tool is the tried and tested way to work with containers on any platform, including Windows. With the Docker command line, you can manage, configure, and carry out lifecycle management for all your containers. First, let’s look at a few commands.
- docker pull
- docker run
- docker ps
- docker inspect
- docker commit, save, load, export, and import
Docker pull
The first command we want to look at is the docker pull command. You will become very familiar with the docker pull command working with Docker. It is the command allowing you to pull down container images to run on your container host. Below is an example of pulling down the latest servercore:ltsc2022 tagged image from Microsoft.
The command for pulling down the image is:
Docker pull mcr.microsoft.com/windows/servercore:ltsc2022
Docker run
The docker run command is the next command you will become familiar with. The docker run command spins up the container to a running state, allowing it to serve resources. Then, it uses the image you specify to build and run a new container.
The command for running a Docker container in Windows with the interactive flag is the following:
docker run -it mcr.microsoft.com/windows/servercore:ltsc2022
Below, we have a shell open interactively in the container itself, as evidenced by the hostname command.
BDRSuite offers comprehensive Hyper-V VM backup and recovery options
Docker ps
The docker ps and the docker ps -a commands are essential to know when working with Docker containers. The docker ps and docker ps -a commands provide information about the running and all containers (running and not running), respectively.
Docker ps shows only the containers running on a Docker host, while docker ps -a show all the containers, regardless of whether these are running or not.
docker ps | docker ps -a
Docker inspect
The docker inspect command allows you to see all the advanced details of Docker containers in your environment. It allows you to see intricate details, such as the volume mounts for the container, detailed networking information, and many other details.
Just a few of the selected bits of information you will see from running a docker inspect are the following:
- creation date
- path
- args
- state
- image
- logpath
- restart count
- binds
- networkmode
- portbindings
- restartpolicy
- dns
- dnsoptions
- dnssearch
- isolation
- cpushares
- memory
- nanocpus
- graphicsdriver
- networksettings
- macaddress
- networks
- aliases
- ipaddress
- gateway
Keep your virtual machines secure with BDRSuite’s Hyper-V VM backup capabilitie
Docker commit, save, load, export, and import
Several Docker commands are used for saving, exporting, and migrating Docker containers. These are the docker commit, save, load, export, and import commands. With these commands, you can do the following:
- docker commit – Commit changes made to a specific container into a new image
- docker save – The docker save command allows saving an image to a compressed .tar file
- docker load – The docker load command allows loading an image from a repository or .tar file created with the docker save command
- docker export – You can export a container, not image with the docker export command and save these to a compressed .tar file
- docker import – Import an exported Docker image contained in a .tar file
Windows Admin Center
Windows Admin Center provides many capabilities, although not nearly as many as using the Docker command line. However, in its current stage, it is an excellent tool for viewing your container estate and even performing an export of an IIS website to a working container, something you can’t do from a straight Docker command line.
Windows Admin Center provides a nice overview dashboard of the containers running on your Windows Server container host.
Below are a few images of working with containers in the Windows Admin Center. Not you can pull, push, create, or delete images in the images section.
Note the possibility of creating a Docker container from an existing Windows IIS web application.
While there are not as many detailed operations and specific tasks you can perform in Windows Admin Center, it is a great alternative for working with basic container operations in a Windows environment. It provides everything you need to create, start, stop, and even migrate existing applications to containerized environments.
Wrapping Up
There are many great tools for working with Docker containers in Windows for beginners and experienced Docker administrators. Windows Admin Center provides an excellent GUI interface for those unfamiliar with the Docker command line while still providing the ability to perform basic operations and lifecycle management.
However, it also has tricks up its sleeve, with the ability to migrate existing web applications from IIS. It will undoubtedly be an excellent tool for those looking to migrate away from full IIS websites running on full virtual machines to containerized environments.
5 Reasons to Use Hyper-V Containers
Beginners’ Guide for Microsoft Hyper-V: How to run IIS in Docker Container – Part 38
Beginners’ Guide for Microsoft Hyper-V: Windows Docker Container Networking in Hyper-V – Part 37
Beginners Guide for Microsoft Hyper-V: Top 8 Basic Docker Commands You Should Know – Part 36
Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.