Media & Entertainment
Today, container technology is one of the most popular and essential tools for producing and deploying various applications. Docker is one of them. It has gained popularity over the past years and has been using this technology as a native system. But container technology was designed only for Linux or server systems.
At the same time, most regular users use Windows as their primary system and cannot install other systems. There are several solutions for such users on the Windows platform that allow them to get experience with the Docker system and make deployment for simple or unloaded projects.
Currently, the most popular components are Docker Toolbox and Docker for Windows, which provide all the necessary components to run Docker on Windows. Let’s take a deeper look below at their features and options in terms of simplicity and functionality for a regular user.
We assume that the reader of this blog knows the Docker basics so that we will focus only on the main and distinctive features.
Let’s say right away that Docker solutions for Windows use system resources not in a direct way, but with the technology of Virtual Machines (VM). By default, the Docker Toolbox uses VirtualBox, which creates a special terminal with Docker Machine, while Docker for Windows uses Hyper-V virtualization technology. These tools make it easy to run the Docker on a Windows platform in just one step. Let’s see how all of these components interact with each other in the following diagram.
The diagram describes in steps the implementation of Docker’s functionality and capabilities for Windows platforms:
Usually, all these steps are performed by the start script with Docker Terminal. Such number of steps is explained by the fact that Docker uses Linux features that Windows doesn’t currently support. Note that the Linux version can perform all these steps only in one step.
An important step in the interaction between Docker and Windows is to choose the appropriate tool: Docker Toolbox or Docker for Windows. Their algorithms for interacting with Windows are similar in general but have their features and usage requirements, so let’s explore them in more detail below.
Docker for Windows (or Docker Desktop) is the most up-to-date version of Docker at the moment. It requires Windows 10 Pro, Enterprise, or Education version. Home edition doesn’t support it since the Hyper-V virtualization service cannot be installed on it. The disadvantage of this solution is that you will not be able to run other VM services for your purposes.
Docker Toolbox is an older version of the Docker that is not currently being updated. At the same time, it is also popular because it has lower system requirements, which means supporting VM VirtualBox. So, if you are using older versions of Windows or even macOS, then Docker Toolbox is a simple and practical solution to use Docker service. It should be noted that the functionality of the Docker Toolbox, in general, allows you to perform all the necessary deployment tasks.
There is also another one, a complex and time-consuming solution It is based on using VM and installation procedures for one of the Linux distributions and configuring Docker for it. This solution is not for all users as it includes several DevOps tasks that generally complicate the deployment process.
The decision to choose a specific solution depends primarily on the platform and the purpose of using Docker. In general, if system requirements allow you to use Docker for Windows, we recommend you to use it as the most relevant and functional system. However, for this topic, we will use Docker Toolbox as an example of the most frequently used version at the moment.
The installation process of the Docker Toolbox for Windows is simple and intuitive since all components are included in one package. All details of the installation are described in the official guide, so we’ll focus only on the main aspects and features of installation and configuration.
The installation process involves several main steps, let us briefly describe them:
Note: A selection of these components depends on your requirements. We advise you to select the option “Full installation”, as the components are lightweight and will not take up much system resources.
Note: this step for the first time will take a relatively long time (depends on the choice of VirtualBox hardware setup), but the next time the launch will be faster.
If you’ve done all these steps correctly, the terminal will show you the command line with an ASCII art picture with Whale and an IP address which is important for future operation with Docker Terminal and Windows.
Now we have the terminal prepared to accept and execute Docker commands.
Note: Docker Quickstart Terminal command line uses bash, which is the Linux command.
Docker Toolbox provides several services, utilities, and tools that create a Linux virtual machine with Docker functionality. For a deeper understanding of their interactions, let’s show them in the following chart.
As we can see, the Docker Machine is the connection and control component between Docker Toolbox and Windows. Next, we’ll use it in our Deployment examples.
Docker represents a client/server architecture and contains several basic components that access the server using the REST API interfaces. Therefore, we will describe them briefly below for a better understanding of the Docker Toolbox workflow in Windows.
In view of the chart above, let’s describe the Docker Toolbox workflow.
In general, these steps are the same as for Linux systems, except for the first and last. The main differences are in the configuration and use of VM.
Once the container is started, all actions are moved to its level. These operations differ from the native version only by what is inside VM. Therefore, we will not review them in detail and will focus only on the key steps:
There are some features and details that appear with Docker Toolbox that are specific only for Windows. The Mounting of extra folder and files is one of these features that most users come across in their work, so let’s review and describe it.
The Docker settings allow limited access to the file system. And in case you place your project outside your home folder, you will need to connect it using VirtualBox settings. It is necessary to do the following actions:
After that, the Docker Machine will access the files in a shared folder. But it’s important to note that all files and folders mounted from the host machine will be set to 755 (rwx r-x r-x) access mode.
We reviewed aspects of Docker Toolbox’s interaction with Windows and highlighted key workflow steps specific to this system. Now, we will show the deployment process for Windows by examples.
When we run Docker Images, these images will be inside VM. So to access them, we’ll need the VM’s IP-address which we got earlier with starting Docker Machine. This is a private address in a virtual network on PC, so let’s check to see if the Windows command line can access the created Docker Machine host.
So we got a response and Windows PC can connect to the VM with Docker image.
We’ll use the images on the Docker Hub and run hello world containers for testing purposes on the Windows system.
As we can see, the HelloWorld image is running, and it shows that we have successfully created a Docker container on the Windows platform.
Next, let’s follow the same approach and put in the container a simple page site. But unlike the previous example, in addition to the basic commands, we’ll use flags to configure the container more precisely.
The first thing we will do is to run the image and select the flags (parameters) in such a way that the resulting hosting was shared and did not depend on the terminal.
After the docker executes the command, we see that the image was downloaded successfully. Now let’s check if this image is running as a container.
As a result, we see that the container and the associated host from the simple page site is running. We can verify this by navigating to the appropriate IP address and port with a browser.
Now, we have a web server with a simple page running inside a Docker container on Windows. As you can see, this process is quite simple, and it takes just a few minutes. Using the same approach you can create your images and containers to run your software.
Besides the fact that we can perform various operations on prepared images (or create them), we can also manage containers with Docker Machine. Let’s demonstrate this by creating a new host.
The first thing to do is to check the VM list.
We can see that we have one VM created during the previous steps. But now we are going to add another one, which will possibly host other software.
Then we make sure that VM is created and ready to work with containers.
As a result, we got another VM, which will allow us to deploy containers for other tasks using the approach above.
Also, the task of connecting Windows to remote VM environments often appears. To do it, you need to define and set values of environment variables.
But with this solution, a problem appears that the variable values are set only for the current terminal. So, it is necessary to automatize the process with a bash script or to use a more flexible solution.
We reviewed the basic operations that are required to work with the Docker Toolbox and Docker Machine on Windows. A list of full functionality and commands is available on the official site.
In this blog, we have discussed the aspects of running Docker on Windows. We focused on the Docker Toolbox for Windows solution and provided basic installation instructions and usage patterns.
Perhaps this material will help and simplify the Deployment process for your applications with Docker and Windows. But at the same time, if you want to get a smoother development experience with Docker, then we recommend using the native version for Linux systems.