Kahibaro
Discord Login Register

3.2 Docker on Windows

Choosing the Right Docker Option on Windows

On Windows you have two main ways to run Docker, Docker Desktop and the older Docker Toolbox. Today, Docker Desktop is the standard choice for most users and Docker Toolbox is kept only for very old Windows systems. Docker Desktop uses a lightweight Linux virtual machine behind the scenes, because containers are based on Linux kernel features. You interact with Docker through Windows, while the actual container processes run inside that VM.

If you use Windows 10 or Windows 11 with a supported edition and build, Docker Desktop is almost always the correct option. If you are on a much older or unsupported version of Windows, Docker support becomes limited and some features described in the rest of this course may not work as shown.

On modern Windows systems, always prefer Docker Desktop. Use older solutions only if your Windows version cannot run Docker Desktop.

Requirements and Prerequisites

Before installing Docker on Windows, you must ensure your system meets some important requirements. First, you need a 64 bit version of Windows. Second, you must have hardware virtualization enabled in your system BIOS or firmware. This lets Windows run the Linux virtual machine that Docker uses. Without virtualization, Docker Desktop cannot start its backend.

On Windows 10 and Windows 11, the recommended configuration uses the Hyper V and WSL 2 technologies. Hyper V is Microsofts virtualization system and WSL 2 is the second generation Windows Subsystem for Linux. Docker Desktop relies on one or both of these depending on which backend you choose during setup. Different Windows editions expose these features differently and in some Home editions Hyper V is limited, so Docker Desktop usually prefers WSL 2.

You also need sufficient memory and disk space. Containers and images will consume disk space in the virtual machine image managed by Docker Desktop. For a smooth beginner experience, at least 8 GB of RAM is strongly recommended, especially if you plan to run databases and multiple services together.

Before installing Docker Desktop, ensure that hardware virtualization is enabled and that your Windows edition supports WSL 2 or Hyper V.

Installing Docker Desktop on Windows

To install Docker Desktop on Windows you download an installer, run it, and follow a guided setup. The installer registers Docker as a standard Windows application and configures the virtualization backend. During installation you may be asked whether you want to use WSL 2 or Hyper V. For most current systems, WSL 2 is the recommended choice, because it provides good performance and integration with existing Linux tooling.

The installation process also sets up the Docker Engine inside the Linux environment, configures the system tray application, and adds the Docker CLI to your Windows PATH. After the installer completes, you usually have to log out and log back in or restart Windows, so that any new system components are loaded and environment variables become active.

Once installation is finished, you start Docker Desktop like any other application. When it starts, Docker Desktop launches the Linux virtual machine in the background. Only after that virtual machine is running will Docker commands from your terminal actually work. The first start can take longer, because Docker Desktop prepares the internal VM filesystem and networking.

Complete the Docker Desktop installer, then restart Windows if prompted, and always start Docker Desktop before using Docker commands.

Configuring Backend and Integration

After installation, Docker Desktop for Windows provides a settings panel where you can adjust how Docker runs. One key area is the choice of backend, which is usually between a WSL 2 based backend and a Hyper V based backend. You can switch between them if your Windows edition supports both, but changing the backend may require a restart of Docker Desktop and sometimes a reboot.

Another important area is resource allocation. Inside settings you can limit how much memory, CPU, and disk space the Docker virtual machine is allowed to use. If your containers feel slow or run out of memory, you can increase these limits, as long as your host system has enough resources. On the other hand, if Docker consumes too much of your laptops resources, you can reduce the limits to keep the rest of your system responsive.

Docker Desktop can also integrate with WSL distributions so that you can run the Docker CLI directly from a Linux shell inside WSL. In this configuration the CLI in WSL talks to the Docker Engine managed by Docker Desktop. This setup is popular with developers who prefer a Linux shell but still want to work from a Windows environment.

Always ensure that the selected backend and resource limits in Docker Desktop match your Windows capabilities and your project needs.

File System and Path Considerations

On Windows, file paths and volumes behave differently than on Linux, so Docker Desktop includes special handling. The containers still see a Linux style filesystem inside the virtual machine. When you mount Windows folders into containers, Docker performs a translation between Windows paths and Linux paths. This allows you to share your project files from the Windows filesystem with containers.

You typically need to grant Docker Desktop permission to access specific Windows drives or directories. In the settings, you can enable or disable drive sharing for paths such as C, D, or a custom folder. If a drive is not shared, attempts to mount it into a container will fail. For security and performance reasons, it is good practice to share only the drives you actually need for development.

You must also pay attention to case sensitivity and line endings. Windows filesystems are usually case insensitive, while Linux filesystems are case sensitive. Inside containers, file paths follow Linux behavior. This means that a file named Dockerfile is different from dockerfile inside the container, even if Windows treats them as the same. This detail can affect build contexts and volume mounts in subtle ways.

When working with volumes on Windows, always verify that the target drive is shared in Docker Desktop and remember that containers see a Linux style filesystem.

Using the Docker CLI on Windows

After you start Docker Desktop, you can access Docker through different terminals. There is the classic Windows Command Prompt, PowerShell, and also PowerShell Core. The Docker installer integrates the docker command into the PATH so you can run commands from any of these shells. Each shell has its own rules for quoting and escaping, which affects how you type Docker commands, especially when you pass environment variables or complex arguments.

If you use WSL, you can also open a Linux terminal and use the docker CLI from there, as long as Docker Desktop is configured to expose its engine to WSL. In that case, path handling inside the terminal is entirely Linux style, which can be more straightforward for commands that rely on Unix file patterns or scripts.

The underlying Docker Engine behaves the same regardless of which terminal you use. Only the way you type commands changes. For example, environment variable interpolation in a PowerShell terminal is different from Bash in WSL. This distinction becomes important later when you use Docker Compose configuration files and scripts, but the containers themselves are unaffected by the terminal choice.

Use any shell you prefer on Windows, but be consistent, because each shell handles quoting, paths, and environment variables differently when you run Docker commands.

Containers with Windows and Linux Images

On modern Windows systems, Docker Desktop is optimized for Linux containers. That is the default mode. The Linux containers run inside the WSL 2 or Hyper V based virtual machine. Some versions of Docker Desktop also allow a Windows containers mode, which uses native Windows container technology with Windows based images. Switching between Linux and Windows containers changes which type of images you can run.

Linux containers are far more common and are the main focus of this course. They are portable across Linux servers and cloud providers because they all depend on the Linux kernel in the virtual machine. Windows containers, in contrast, depend on the Windows kernel, so they target specific Windows Server versions and have more limited portability.

You can usually see which mode you are using from the Docker Desktop interface. Before running an image, verify that it matches the current mode. For example, pulling and running a typical open source web server image will require Linux containers mode. If you accidentally stay in Windows containers mode, such commands will fail until you switch back.

Always match the container mode to the image type. Use Linux mode for Linux images and Windows mode only when you explicitly need Windows based images.

Updating and Uninstalling Docker Desktop

Docker Desktop receives regular updates that include security patches, new features, and bug fixes. On Windows you can enable automatic update checks in the settings so that Docker Desktop reminds you when a new version is available. Running an up to date version reduces compatibility problems with images and tools that rely on newer Docker features.

If you need to uninstall Docker Desktop, you do so through the standard Windows application management. Uninstalling removes the main application and the virtual machine environment. It can also remove images, containers, and volumes stored inside the Docker data directory, depending on the options you select during removal. If you want to preserve data, back up the relevant volumes or directories before uninstalling.

Reinstalling Docker Desktop is usually straightforward. If you remove the previous configuration completely, the new installation will behave like a fresh setup and you will need to recreate your settings and re pull images as required.

Keep Docker Desktop updated for security and compatibility, and remember that uninstalling it can permanently delete containers, images, and volumes stored in its data directories.

Views: 8

Comments

Please login to add a comment.

Don't have an account? Register now!