Docker Desktop for Windows allows you to get a graphical user interface (GUI)-based handle on your Docker environment. It aims to make it easier for you to view and manage the state of containers and related artifacts in your environment.
Latest posts by Edem Afenyo (see all)

In this tutorial, I will teach you how to use Docker Desktop to tame your Docker environment on Windows.

Prerequisites

This tutorial uses Docker Desktop on Windows 10. Install Docker Desktop on Windows if you do not already have it installed. You can also follow along with Docker Desktop on Linux or macOS.

Pulling images into Docker Desktop

Starting Docker Desktop for the first time (if you haven't done anything with Docker before) opens up a dashboard with no images or containers, as in the screenshot below.

Listing containers at the first start

Listing containers at the first start

This is normal, as Docker Desktop is primarily meant to assist with managing an existing Docker environment. By implication, Docker Desktop has no native method to pull images from the GUI. You will first have to create some resources with the Docker command line interface (CLI) to have anything to work with in the GUI. And that is exactly what you will do in this section.

Open up a terminal emulator and pull the latest Nginx image.

docker pull nginx:latest

Your screen should be filled with progress reports, as the image is downloaded:

Pulling a Docker image

Pulling a Docker image

Once complete, it should show up in Docker Desktop under the Images panel, as in the screenshot below:

Viewing images in Docker Desktop

Viewing images in Docker Desktop

Viewing vulnerabilities for images

Before running a container, it might be interesting, from a security standpoint, to know what vulnerabilities affect the image you plan to use.

Select the nginx image entry, as in the screenshot below, to get more information.

Viewing image details

Viewing image details

You should get a count of vulnerabilities according to severity. You can also see the layers and images that make up the Nginx image.

Listing known image vulnerabilities

Listing known image vulnerabilities

Running containers with Docker Desktop

Click the Run button on the details page to create a container from this image.

Running a container

Running a container

Click Run in the popup window that appears, as below.

Running a container

Running a container

The Optional Settings menu has been expanded in this screenshot.

Running a container listing optional settings

Running a container listing optional settings

This popup window gives you the chance to configure the container with options that are available via the CLI. For example, you can name the container, expose some ports, or attach a volume to it.

Leaving all the fields as they are results in a container with the default configuration.

Investigating containers

Running a container takes you directly to the container details page. On the Logs tab, you will see logs related to the running container, as below.

Viewing container logs

Viewing container logs

Select the timestamp button to toggle timestamps on and off. This feature can reduce the effort required to sift through while troubleshooting container issues.

Toggling timestamps off

Toggling timestamps off

Here is the same view with timestamps enabled, for comparison.

Toggling timestamps on

Toggling timestamps on

Under the Inspect tab, you can view details about the container's internal environment. As you can see in the screenshot below, the Inspect tab gives you access to the environment variables from Docker Desktop.

Inspecting container environment variables

Inspecting container environment variables

Running commands in the container with an integrated terminal

Docker Desktop comes with an integrated terminal that allows you to run commands within the container directly from the GUI. This is like running the "docker exec" CLI command with interactivity.

Switch to the Terminal Tab and get a container command prompt.

Opening the integrated terminal

Opening the integrated terminal

You can confirm both the ability to run commands and the fact that the commands are run within the container by executing the hostname command:

hostname

As you can see from the screenshot below, the hostname returned is the hostname of the container, not the Windows host machine.

Running commands in the integrated terminal

Running commands in the integrated terminal

Performing basic container actions

Head back to the Container panel. There is more you can do with containers in Docker Desktop. In this section, you will learn to control running containers with Docker Desktop.

Opening the container

Opening the container

Pausing a Container

To pause a running container, select Pause from the More Options menu under Actions. Pausing a container saves its state in memory and frees up CPU resources.

Pausing a container

Pausing a container

You can resume the container by clicking Start in the Actions column. Notice how the status changed from Running to Paused in the screenshot below, confirming the change.

Resuming a paused container

Resuming a paused container

Restarting a container

You can also restart a running container directly by selecting Restart from the More Options menu under the Actions column.

Restarting a container

Restarting a container

Stopping a container

Once done with a container, you can stop it from the Actions column by clicking the stop icon.

Stopping a container

Stopping a container

Deleting a container

You can also delete a container altogether by clicking the delete icon, as shown below.

Deleting a container

Deleting a container

Deleting an image

Now that there are no containers using the nginx image, you can delete it by going to the Images panel. Deleting images allows you to reclaim storage space for other uses.

Listing available images

Listing available images

Confirm that the image is not being used by checking the Status column. It should read Unused, as in the screenshot below.

Confirming an image is not in use

Confirming an image is not in use

Click the Delete icon to delete the image. It is important to note that images cannot be deleted if they are being used by a container. Confirm your choice in the popup that will follow.

Deleting an unused image

Deleting an unused image

Managing volumes with Docker Desktop

Volumes are another resource Docker Desktop allows us to manage. Unlike images, you can create volumes directly from Docker Desktop, as well as manage those created with the CLI.

Open the Volumes panel, as shown below.

Listing available volumes

Listing available volumes

Docker begins with a list of available volumes. Since none has been created yet, it reports an empty list.

Click Create to create a new volume.

Creating a new volume

Creating a new volume

Supply an appropriate name, and click Create. This tutorial uses my-vol, but you can use any name you want.

Creating a new volume Naming the volume

Creating a new volume Naming the volume

The list of volumes should now have an entry, as shown in the screenshot below. You can also create more volumes and attach them to containers as part of the container creation process. Docker Desktop allows you to view all volumes in your environment along with their sizes.

Displaying the created volume

Displaying the created volume

You can delete unused or unwanted volumes by clicking the Delete icon, as shown below:

Deleting volumes

Deleting volumes

Confirm the deletion, as in the following screenshot, to remove the volume.

Confirming volume deletion

Confirming volume deletion

Using extensions to improve container management

Docker Desktop can be even more useful if you enhance its capabilities with extensions. In this section, you are going to learn to add the Resource usage extension, which gives you a holistic overview of utilization in your environment.

Click Add Extensions to open up the extensions marketplace.

Adding extensions

Adding extensions

Begin to type in the name of the extension, Resource usage, until the extension comes up for install.

Searching for an extension

Searching for an extension

Click Install to add it to your Docker Desktop.

Installing an extension

Installing an extension

Select Resource usage under Extensions to get a feel for what metrics it collects and displays. If you have no containers, the panel should be empty, as shown in the screenshot below.

Viewing resource utilization

Viewing resource utilization

Troubleshooting errors with adding extensions

There is a known bug that can come up while you are trying to install new extensions. If you get a notification that "the local image you are trying to install has been modified and is different from the published image," don't fret.

Navigate to the Docker contexts folder at %userprofile%\.docker. The local user account for this tutorial is named "as:"

Troubleshooting extension installation

Troubleshooting extension installation

Delete the contexts folder, restart Docker Desktop, and try adding the extension again.

Conclusion

Congrats! By coming this far, you have learned how to use Docker Desktop to manage images, containers, and volumes. With this knowledge, you can harness the benefits of Docker Desktop to streamline your development or sysadmin workflow.

Subscribe to 4sysops newsletter!

As a next step, you can explore the Extensions marketplace to see what is on offer to ease up your container administration experience.

avataravatar
0 Comments

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2023

CONTACT US

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

Sending

Log in with your credentials

or    

Forgot your details?

Create Account