Toad World Blog

Using Docker Windows Containers with Databases

Jan 22, 2018 4:19:29 PM by Deepak Vohra

Docker for Windows was introduced recently. Docker for Windows runs Docker containers on Windows OS similar to running Docker containers on Linux platforms. The novelty of Docker for Windows is Docker Windows containers. Docker Windows containers differ from Docker Linux containers in that they run on Windows OS. The essential concept is the same – Docker containers running in isolation on an underlying OS with each having its own networking and filesystem. 

Windows is the most commonly used desktop OS and Docker for Windows has made it feasible to run Docker on Windows. In this tutorial we shall introduce running Windows containers with Docker for Windows.  We shall also introduce running some of the commonly used databases in Docker Windows containers. This tutorial has the following sections.

  • Setting the Environment
  • Setting Windows Containers Mode
  • Using Windows PowerShell
  • Testing Docker Windows Containers
  • Creating a Docker Image and Running a Docker Container
  • Uploading a Docker Image to Docker Hub
  • Setting the Docker Swarm Mode
  • Creating a Docker Service
  • Creating a Dockerfile
  • Creating a Docker Image from Dockerfile
  • Running a Docker Container from Docker Image
  • Using Prebuilt Docker Images for Database
  • Removing Docker Containers and Docker Images

 

Setting the Environment

Docker for Windows  supports Windows 10 and Windows Server 2016.  Create an instance on a local machine or on an AWS EC2 instance running Windows 10 or Windows Server 2016 OS.  We have used a Windows Server 2016 instance running on AWS EC2.  Launch a Windows Server 2016 instance on EC2 with Microsoft Windows Server 2016 with SQL Server 2016 Express AMI as shown in Figure 1.

 

Figure 1. Windows Server 2016 Instance on EC2

The required connection parameters, which would be different for different users, may be obtained with Connect, as shown in Figure 2.

 

Figure 2. Connect

Find the password in the Connect To Your Instance wizard. Copy the following information, which is required to connect to the Windows Server 2016 instance on EC2 using remote desktop client such as Chrome RDS.

Public DNS   ec2-54-210-145-61.compute-1.amazonaws.com

User name    Administrator

Password

Subsequently connect to the Windows Server 2016 instance from a local machine using Chrome RDS. Install Docker for Windows (Stable or Edge edition) from https://docs.docker.com/docker-for-windows/install/. The Edge edition is used in this tutorial, as shown in Figure 3.

Figure 3. Docker for Windows Edge

Setting Windows Containers Mode

By default, when Docker for Windows is started one of the modes is configured: Linux containers or Windows containers. To find which mode is preset click on the ^ button and right-click on the Docker icon. If the Linux containers mode is preset the option to switch to the Windows containers mode is listed. as shown in Figure 4. Click on Switch to Windows containers… as shown in Figure 4.

Figure 4. Switch to Windows containers…

The message Docker is switching… gets displayed, as shown in Figure 5.

Figure 5. Switching to Windows containers

The dialog “Containers feature is not enabled” gets displayed, as shown in Figure 6. To enable the Containers feature click on OK. As indicated in the dialog the machine restarts after the mode is switched to Windows.

Figure 6. “Containers feature is not enabled” Dialog

The Windows machine restarts, as shown in Figure 7.

Figure 7. Restarting Windows machine

The Connect wizard for the remote desktop client (Chrome RDP or another) gets restarted. Select the Public DNS of the Windows Server 2016 machine and click on Connect as shown in Figure 8.

Figure 8. Reconnecting to Windows Server 2016

After the Windows Server 2016 is relaunched the message “Docker is running” gets displayed, as shown in Figure 9.

Figure 9. Docker is running

How to verify the mode has been switched to Windows containers? In the same dropdown in which the containers mode was switched to Windows, the option Switch to Linux containers… should get displayed, as shown in Figure 10.

Figure 10. Switch to Linux containers…

Using Windows PowerShell

Docker for Windows is designed to be used with Windows PowerShell, which is a task automation and configuration management framework consisting of a command-line shell that runs a scripting language based on .NET Framework and .NET Core.  To launch Windows PowerShell select Windows PowerShell from the Windows applications as shown in Figure 11.

Figure 11. Selecting Windows PowerShell

The Windows PowerShell command-line shell gets started, as shown in Figure 12.

Figure 12. Windows PowerShell

The docker commands may be run in the Windows PowerShell to build images, run containers and run Docker services.  The docker version command lists the Docker version, as shown in Figure 13. By default Docker for Windows (Stable and Edge) is set to Experimental mode as indicated by the “Experimental” attribute.

Figure 13. The output from docker version Command

Experimental mode is only for a development environment and not suitable for Production. The Experimental features checkbox may be deselected in Settings>Daemon as shown in Figure 14.

Figure 14. Settings>Daemon>Experimental features

Testing Docker Windows Containers

Docker Windows containers may be run using the docker run command, similar to running Docker Linux containers with one essential difference. The Windows containers run on Windows OS and the Docker images for Windows containers have to be based on a Windows OS. In terms of Dockerfile for a Docker image that may be used to run Windows containers, the FROM instruction in the Dockerfile must be for a Windows OS. This implies that the Docker images that are used to run Docker containers on a Linux platform and are familiar to most Docker users cannot be used to run Windows containers.  Several Docker images, such as microsoft/nanoserver and microsoft/windowsservercore, which are based on Windows OS are available on Docker hub. As an example, run a Docker Windows container with the microsoft/nanoserver Docker image. The Docker image microsoft/nanoserver may be pulled with a docker pull command as shown in Figure 15. Subsequently list the Docker image with the docker images command.

Figure 15. Pulling and listing Docker image microsoft/nanoserver

Run a Windows container with the Docker image microsoft/nanoserver using the docker run command.  A Windows container gets created.

PS C:UsersAdministrator> docker run microsoft/nanoserver hostname

c2609ca0c927

Subsequently list all containers (running and exited) and the Windows container should be listed. The Windows container has exited after running the “hostname” command.

PS C:UsersAdministrator> docker ps -a

CONTAINER ID        IMAGE                  COMMAND             CREATED             STATUS                      PORTS

           NAMES

c2609ca0c927        microsoft/nanoserver   "hostname"          36 seconds ago      Exited (0) 31 seconds ago

           boring_yonath

As an another example of running Docker Windows containers, run a Windows container with the hello-world image, which provides an image for both Linux and Windows platforms.

docker run hello-world

As shown in Figure 16, a Docker container gets started with the hello-world image.

Figure 16. Running a Docker Windows Container with hello-world Docker image

The output from the docker run hello-world command lists a docker run command to run a Windows Server container.

docker run -it microsoft/windowsservercore powershell

Run the preceding command and a new PowerShell command shell gets started, as shown in Figure 17.

Figure 17. Running a PowerShell command shell for Windows Server

The Windows container for the Windows Server has its own filesystem and networking. As shown in Figure 18, the files and directories in the Windows container may be listed with the dir command.

Figure 18. Listing Files and Directories in the Windows Container PowerShell

To exit the PowerShell for the Windows Server Windows container, specify exit and the command prompt returns to the Windows PowerShell session from which the Windows container for Windows Server was started, as shown in Figure 19.

Figure 19. Returning to the Windows PowerShell Command Prompt

Creating a Docker Image and Running a Docker Container

In the preceding section we ran a Windows container with the microsoft/nanoserver Docker image. In this section we shall use the microsoft/nanoserver Docker image as the base image to create a new test image for Windows containers. A new Docker image for Windows containers may be created using a Dockerfile (as discussed in a later section) or by specifying the Dockerfile instructions on the command line. As an example, create a Docker image called dvohra/windows-test-image for Windows containers with the base image microsoft/nanoserver. The new Docker image dvohra/windows-test-image includes a CMD to output a “Hello World” message.

PS C:UsersAdministrator> "FROM microsoft/nanoserver `n CMD echo Hello World!" | docker build -t dvohra/windows-test-image -

Sending build context to Docker daemon  2.048kB

Step 1/2 : FROM microsoft/nanoserver

 ---> 00f2c6e8b100

Step 2/2 : CMD echo Hello World!

 ---> Running in 5e29fee0d6ed

 ---> 13860679b2b3

Removing intermediate container 5e29fee0d6ed

Successfully built 13860679b2b3

Successfully tagged dvohra/windows-test-image:latest

A Docker image called dvohra/windows-test-image:latest gets created and gets listed with the docker images command.

PS C:UsersAdministrator> docker images

REPOSITORY                  TAG                 IMAGE ID            CREATED              SIZE

dvohra/windows-test-image   latest              13860679b2b3        About a minute ago   1.08GB

microsoft/nanoserver        latest              00f2c6e8b100        10 days ago          1.08GB

Next, run a Docker container with the Docker image dvohra/windows-test-image:latest. A “Hello World!” message gets output.

PS C:UsersAdministrator> docker run dvohra/windows-test-image

Hello World!

Uploading a Docker Image to Docker Hub

Having built a Docker image for Windows container, the image may be uploaded to the Docker Hub if a Docker Hub account is created for a user. First run the docker login command to login to the Docker Hub. Specify the password at the Password prompt.

PS C:UsersAdministrator> docker login

Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.

Username: dvohra

Password:

Login Succeeded

Upload the Docker image dvohra/windows-test-image with the docker push command.

PS C:UsersAdministrator> docker push dvohra/windows-test-image

The push refers to a repository [docker.io/dvohra/windows-test-image]

626560bf6b66: Pushed

3b70401681d4: Skipped foreign layer

6c357baed9f5: Skipped foreign layer

latest: digest: sha256:35c2fba64e7e9c451380748b40e54a0495ae9ede1a67ecc7eb5e075e58ac92e9 size: 1150

The Docker image for Windows containers dvohra/windows-test-image gets uploaded to the Docker hub as shown in Figure 20. The Docker image may be tagged differently by different users as Docker image dvohra/windows-test-image won’t get uploaded to different user accounts on Docker hub.

Figure 20. Docker Image dvohra/windows-test-image on Docker Hub

The tags for the Docker image dvohra/windows-test-image list a single tag “latest” as shown in Figure 21.

Figure 21. Tags for Docker image dvohra/windows-test-image

Setting the Docker Swarm Mode

In the preceding sections we used the docker run command to run Docker Windows containers with Docker images based on Windows OS.  The Docker Swarm mode may be set in Docker for Windows to create Docker services.  First, create a Docker Swarm with the docker swarm init command using the Private IP Address of the host Windows Server 2016 instance, which may be obtained from the EC2 management console as already shown in Figure 1. The Private IP address is listed with the Private IPs label.

PS C:UsersAdministrator> docker swarm init --advertise-addr 10.0.0.138

Swarm initialized: current node (nytx2hvq53vez1eywslwsar6e) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-5fjd6ho7nif39djqu7fn4r6cbep7wh1h1ztzougy03feoxke5q-9q8p6slz8tzrkbp33z2qtxm0x 10.0

.0.138:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

The Swarm mode gets set and the current node becomes the Swarm manager. The docker swarm join command to join worker nodes to the Swarm also gets output.  The preceding command, as the earlier commands, is to be run in the PowerShell as shown in Figure 22.

Figure 22. Setting the Docker Swarm Mode

Creating a Docker Service

After the Swarm mode has been set Docker services may be created using the docker service create command. As an example, create a Docker service using the Docker image dvohra/windows-test-image that was created earlier. The following command creates a Docker service called hello-world  consisting of one replica.

docker service create --name hello-world dvohra/windows-test-image

The docker service create command outputs the Docker container ID.

PS C:UsersAdministrator> docker service create --name hello-world dvohra/windows-test-image

j1az8s5nfz3oqfq0bl7enk909

List the Docker services with the docker service ls command, and the hello-world command should get listed. As the Docker Windows container exits after outputting the Hello World! Message, a new Docker Windows container gets started to keep the replication level at 1. The REPLICAS column may list the number of running replicas as 0 if a Windows container has just exited and a new Windows container has not yet been started.

PS C:UsersAdministrator> docker service ls

ID                  NAME                MODE                REPLICAS            IMAGE                              PORTS

j1az8s5nfz3o        hello-world         replicated          0/1                 dvohra/windows-test-image:latest

Or, the REPLICAS column lists replicas as 1/1 if the service replica is running when the docker service ls command is run.

PS C:UsersAdministrator> docker service ls

ID                  NAME                MODE                REPLICAS            IMAGE                              PORTS

j1az8s5nfz3o        hello-world         replicated          1/1                 dvohra/windows-test-image:latest

The docker ps –a command lists both running and exited Windows containers and multiple containers for the Docker service get listed as Windows containers keep running and keep getting exited and new Windows containers keep getting started.

PS C:UsersAdministrator> docker ps -a

CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS

        PORTS               NAMES

d7bbfb2a6ac5        dvohra/windows-test-image:latest   "cmd /S /C 'echo H..."   1 second ago        Created

                            hello-world.1.xw1vyryfjqq1pq81rjh4khw7u

71f1d362163b        dvohra/windows-test-image:latest   "cmd /S /C 'echo H..."   13 seconds ago      Exited (0) 1 second

ago                         hello-world.1.rb4hnp8rv93wbzqdtsnv33lt1

e93bdca11401        dvohra/windows-test-image:latest   "cmd /S /C 'echo H..."   20 seconds ago      Exited (0) 12 second

s ago                       hello-world.1.r4vsrvov8ddrc89c2oq5htvdc

3c964e4b7a9d        dvohra/windows-test-image:latest   "cmd /S /C 'echo H..."   31 seconds ago      Exited (0) 20 second

s ago                       hello-world.1.awxdlai64kwj4p68ja2b6zhvw

69f24b3c4c2f        dvohra/windows-test-image:latest   "cmd /S /C 'echo H..."   37 seconds ago      Exited (0) 31 second

s ago                       hello-world.1.cqvjtj4khzdb5lqfhju1s8aja

fc6032ecc8dd        dvohra/windows-test-image          "cmd /S /C 'echo H..."   17 minutes ago      Exited (0) 17 minute

s ago                       cranky_jennings

c2609ca0c927        microsoft/nanoserver               "hostname"               21 minutes ago      Exited (0) 21 minute

s ago                       boring_yonath

To list the logs for a Docker Windows container run the docker run <container id> command.  The Hello World! message gets listed, as shown in Figure 23.

Figure 23. Listing Logs for a Docker Windows container

The docker service command may be used for other service management such as listing service tasks, scaling a service, updating a service, rolling back a service update, and removing a service, as shown in the docker service command usage in Figure 24.

Figure 24. Command Usage for docker service

Creating a Dockerfile

The Docker image dvohra/windows-test-image:latest for Windows containers was created by running Dockerfile instructions on the PowerShell command line. A Dockerfile is more commonly used to create a Docker image than for running instructions on the command line. Next, we shall create a Dockerfile for a Docker image for Windows containers. A Dockerfile does not include a file extension and may be created with the notepad command.

notepad Dockerfile.

The notepad command to create a Docker file is run in PowerShell, as shown in Figure 25. The command is shown to have returned in Figure 25, but the command returns only after a Dockerfile has opened in a notepad and the Dockerfile saved with File>Save As.

Figure 25. Creating a Dockerfile

A Notepad gets started, as shown in Figure 26, and a dialog prompts the user that the Dockerfile cannot be found and is the Dockerfile to be created.  The file name indicated is actually “Dockerfile .”, but it is only to avoid adding a file extension to Dockerfile. We shall add the Dockerfile instructions and save the file as Dockerfile.

Figure 26. Starting a Notepad Session

Copy the following Dockerfile instructions (or some other instructions) to the Dockerfile. The requirement for a Dockerfile for a Docker image for Windows containers is that the FROM instruction should be for a Windows server.

FROM microsoft/nanoserver

CMD echo Hello World!

EXPOSE 8080

The Dockerfile is shown in Figure 27.

Figure 27. Dockerfile

Select File>Save As.. as shown in Figure 28.

Figure 28. File>Save As…

Save the Dockerfile to the C:/Users/Administrator directory as shown in Figure 29.

Figure 29. Saving Dockerfile to C:/Users/Administrator directory

After saving the Dockerfile select File>Exit to exit Notepad.

The DIR command should list the Dockerfile, as shown in Figure 30.

Figure 30. Listing the Dockerfile

Creating a Docker Image from Dockerfile

A Dockerfile is a template for a Docker image. To create a Docker image from the Dockerfile in PowerShell, run the following command, in which the Docker image is tagged as dvohra/hello-world. The Docker image may be tagged differently by different users.

Get-Content Dockerfile | docker build - t dvohra/hello-world

A Docker image gets built.

PS C:UsersAdministrator> Get-Content Dockerfile | docker build - -t dvohra/hello-world

Sending build context to Docker daemon  2.048kB

Step 1/3 : FROM microsoft/nanoserver

 ---> 00f2c6e8b100

Step 2/3 : CMD echo Hello World!

 ---> Using cache

 ---> 13860679b2b3

Step 3/3 : EXPOSE 8080

 ---> Running in 8ca7e25d45ba

 ---> 06ca007764fb

Removing intermediate container 8ca7e25d45ba

Successfully built 06ca007764fb

Successfully tagged dvohra/hello-world:latest

Listing the Docker images should include the dvohra/hello-world Docker image.

PS C:UsersAdministrator> docker images

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE

dvohra/hello-world            latest              06ca007764fb        20 seconds ago      1.08GB

dvohra/windows-test-image     latest              13860679b2b3        About an hour ago   1.08GB

microsoft/windowsservercore   latest              2cddde20d95d        10 days ago         10.3GB

microsoft/nanoserver          latest              00f2c6e8b100        10 days ago         1.08GB

A tag for the Docker image must be specified, as without one, a Docker image with no repository and no image tag gets built, as indicated by the docker images command issued subsequent to creating a Docker image without a tag.                     

PS C:UsersAdministrator> Get-Content Dockerfile | docker build -

Sending build context to Docker daemon  2.048kB

Step 1/3 : FROM microsoft/nanoserver

 ---> 00f2c6e8b100

Step 2/3 : CMD echo Hello World!

 ---> Using cache

 ---> 13860679b2b3

Step 3/3 : EXPOSE 8080

 ---> Running in 672a1199d82d

 ---> 6c52e2e518f9

Removing intermediate container 672a1199d82d

Successfully built 6c52e2e518f9

PS C:UsersAdministrator> docker images

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE

<none>                        <none>              6c52e2e518f9        6 seconds ago       1.08GB

dvohra/windows-test-image     latest              13860679b2b3        About an hour ago   1.08GB

hello-world                   latest              7bf680dbc0d8        8 days ago          1.08GB

microsoft/windowsservercore   latest              2cddde20d95d        10 days ago         10.3GB

microsoft/nanoserver          latest              00f2c6e8b100        10 days ago         1.08GB

We shall discuss in a later section how a dangling Docker image with repository and tag as <none> may be removed. But first, we shall run the Docker image dvohra/hello-world in the next section.

Running a Docker Container from the Docker Image

The Docker image dvohra/hello-world may be used to create a Docker service with the docker service create command, or a standalone Docker container may be created with the docker run command. Create a standalone Docker Windows container called hello-world with the 8080 port exposed on the host. The Docker container runs and outputs the Hello World! message. If a Docker container by the same name hello-world was created previously it must be removed, as two Windows containers by the same name cannot be created.

docker rm hello-world

PS C:UsersAdministrator> docker run -p 8080:8080 --name hello-world dvohra/hello-world

Hello World!

The Docker Windows container exits after running, as indicated by the docker ps –a command.

PS C:UsersAdministrator> docker ps -a

CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                     PORTS

             NAMES

9847e912476e        dvohra/hello-world   "cmd /S /C 'echo H..."   10 seconds ago      Exited (0) 7 seconds ago

             hello-world

Using Prebuilt Docker Images for Databases

Docker Windows container are relatively new and Docker images for Windows containers are not available for all of the same databases as for Docker Linux containers. But, new Docker images for Windows containers are being added to Docker Hub as their use becomes more common. Prebuilt Docker images for Windows containers are available for several commonly used databases. For example, Docker image microsoft/mssql-server-windows-express may be used for SQL Server Express. Create a Docker Windows container for SQL Server Express with the docker run command.

PS C:UsersAdministrator> docker run -d -p 1433:1433 -e sa_password=sa -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express

Unable to find image 'microsoft/mssql-server-windows-express:latest' locally

latest: Pulling from microsoft/mssql-server-windows-express

3889bb8d808b: Already exists

e29afd68a947: Pull complete

41be53e9dc04: Pull complete

bcc51d185a7f: Pull complete

978a493606df: Pull complete

a930f7aefd81: Pull complete

8ad36c7092f8: Pull complete

4cf45d7ce9ba: Pull complete

1ad578c4d5d8: Pull complete

f931387a33d6: Pull complete

4477ad670f23: Pull complete

90d8977a8378: Pull complete

Digest: sha256:0e8a87f22ad414a7c6a4b30122812e3d66043c8a6541aaed2ecf73020ffd8767

Status: Downloaded newer image for microsoft/mssql-server-windows-express:latest

11891211847f1771517bf44e1974f6eaa02366a9c03f11b2eb9529a71297e8af

Subsequently, list the Docker Windows container with the docker ps command.

PS C:UsersAdministrator> docker ps

CONTAINER ID        IMAGE                                    COMMAND                  CREATED             STATUS

      PORTS                    NAMES

11891211847f        microsoft/mssql-server-windows-express   "cmd /S /C 'powers..."   53 seconds ago      Up 40 seconds

      0.0.0.0:1433->1433/tcp   admiring_davinci

Some of the Docker images already available on Docker Hub, such as the mongo image for Mongo database, have new tags available for Windows containers. The mongo:3.0.15-windowsservercore image may be used to run a Docker Windows container for Mongo database.  Create a Docker Windows container for Mongo database with the docker run command.

PS C:UsersAdministrator> docker run --name mongo -d mongo:3.0.15-windowsservercore

>> 

Unable to find image 'mongo:3.0.15-windowsservercore' locally

3.0.15-windowsservercore: Pulling from library/mongo

3889bb8d808b: Already exists

da87b55a9b63: Already exists

d9a80234ea5a: Pull complete

d141cf8ec84b: Pull complete

f8969f18cc5c: Pull complete

4e936273d27f: Pull complete

39b21f7d0de7: Pull complete

010b228d6f0b: Pull complete

3bdcff95942a: Pull complete

a80c91c9826d: Pull complete

Digest: sha256:662bac9d2881bdd29325670711b4eb9158c80d7d2d2936b2158132c07d735f8e

Status: Downloaded newer image for mongo:3.0.15-windowsservercore

798d8be1babfcdf59b353a558a97628f7cfc9e9d84e2d2ddc2d168de465f40ca

Subsequently a Windows container for Mongo database gets listed with docker ps command.

PS C:UsersAdministrator> docker ps

CONTAINER ID        IMAGE                                    COMMAND                  CREATED              STATUS

       PORTS                    NAMES

798d8be1babf        mongo:3.0.15-windowsservercore           "mongod"                 7 seconds ago        Up 3 seconds

       27017/tcp                mongo

11891211847f        microsoft/mssql-server-windows-express   "cmd /S /C 'powers..."   About a minute ago   Up About a minute   0.0.0.0:1433->1433/tcp   admiring_davinci

Removing Docker Containers and Docker Images

A Docker image may be removed only after all the Docker containers that make use of the Docker image have been removed.  Remove all Docker Windows containers on PowerShell with the following command.

docker rm @(docker ps -aq)

All Docker Windows containers get removed.

PS C:UsersAdministrator> docker rm @(docker ps -aq)

ffd427faf392

b5d7463bee28

52baaa601a41

5fc042378555

65875682fe99

551dc5b99ecb

c9ff2e787623

fc6032ecc8dd

c2609ca0c927

As a replicated Docker service must keep its defined replication level, a new Docker Windows container gets started for the hello-world service based on the Docker image dvohra/windows-test-image.

PS C:UsersAdministrator> docker ps -a

CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS

PORTS               NAMES

8d37cddb72c2        dvohra/windows-test-image:latest   "cmd /S /C 'echo H..."   1 second ago        Created

                    hello-world.1.y2u40pehwzia9foprq0a9toze

A Docker service is removed with the docker service rm command.

PS C:UsersAdministrator> docker service rm hello-world

hello-world

Earlier we discussed how a Docker image with a <none> tag, also called a dangling Docker image, could get created if a Docker image is not properly tagged when built. Dangling images may be removed with the following docker rmi  command.

PS C:UsersAdministrator> docker rmi $(docker images -q -f dangling=true)

Deleted: sha256:6c52e2e518f96335a8a9241cd703d677dfcb52b1ca7fd4f8cc8d9bc522501920

Deleted: sha256:f2c5ec7fbf54151ac547a954226ea621292f5bcb551a758753c8e5ef24f842f9

Docker images that are built as required; Docker images that are not dangling images, may be removed with just the docker rmi command after all Docker containers and services for the image have been removed.

PS C:UsersAdministrator> docker rmi hello-world

Untagged: hello-world:latest

Untagged: hello-world@sha256:1f19634d26995c320618d94e6f29c09c6589d5df3c063287a00e6de8458f8242

Deleted: sha256:7bf680dbc0d82b3d1cbc27a0d83149c09c6cede926dfe5710c16b5222124a3b3

Deleted: sha256:2329170b21d101ef0c95f35cf7dc6326cd1bd9f43ca898d3baf28282363ae5bc

Deleted: sha256:1094a6776aa3e9eec095a3530a26434b7a8ef8f760cdaed538f5e87891485c50

Conclusion

Docker for Windows has introduced Docker to the Windows OS users. Docker for Windows supports both Docker Windows containers and Docker Linux containers. We have discussed only the Windows containers in this article. By default Docker for Windows has the Experimental features mode set, but the Experimental features may be turned off in settings if used in production environment.  Docker for Windows is relatively new and Docker images for Windows containers may not be available for all of the commonly used databases, but new Docker images are added to Docker Hub as Windows containers use becomes more common. Several of the Docker images for databases already available on Docker Hub are adding tags for Windows containers.

 

 

 

 

Tags: Docker Windows

Deepak Vohra

Written by Deepak Vohra

Deepak Vohra is an Oracle Certified Associate, Oracle Database 10g, and Sun Certified Java Programmer. Deepak has published on OTN and in Oracle Magazine.