Docker Windows Containers Not Showing One Directory - Solved
In this article, we will discuss a specific problem users may encounter when working with Docker containers on Windows. The issue arises when a particular directory is not visible inside a Docker container. The focus of this article is on Windows Server 2016 Datacenter version 1607 (build 14393.6614), Docker Desktop Community version 2.0.0.3 (31259), and Ubuntu-based Docker containers in interactive mode.
Background and Key Concepts
Docker is a popular platform for containerization. It allows developers and system administrators to build, distribute, and run applications in containers. Docker containers share the host system's kernel and use isolated resources -- including using specific directories as a part of the container.
Problem Description
A user encountered a problem when working with a Docker container based on an Ubuntu image. The Docker container was started in interactive mode, but one specific directory was not visible from within the container.
Troubleshooting the Problem
The first step when troubleshooting is to verify the problem:
# Start a container in interactive mode
docker run -it --rm -v c:\path\to\directory:/mnt/data ubuntu /bin/bash
In this example, replace "c:\path\to\directory" with the directory on your Windows system that is not showing up in the container. If the problem exists, the contents of the directory will not be visible at /mnt/data when inside the container bash shell.
Finding a Solution
After narrowing down the problem, further investigation revealed that the issue was related to specific combinations of Docker Desktop, Windows Server, and Ubuntu-based Docker containers.
Properly Sharing Directories in Windows for Docker
The solution was to properly configure the Windows host machine to allow sharing the directories with Docker:
-
In the Windows taskbar, right-click the Docker icon and select "Settings":

-
Go to the "Resources" tab and select "File Sharing":

-
Click the Add Folder button, browse to the directory that needs to be shared, and click "Add":

After properly sharing the directories in Docker's File Sharing settings, start a new container in interactive mode using the same command from earlier. Now, the contents of the shared directory should be visible at /mnt/data:
# Start a container in interactive mode
docker run -it --rm -v c:\path\to\directory:/mnt/data ubuntu /bin/bash
The output should include the contents of the shared directory:
$ ls /mnt/data
your_directory_contents_here
-
Docker containers isolate resources but share the kernel with the host system. Sharing directories is important for data exchange.
-
A problem arises when specific directories do not show up inside Ubuntu-based Docker containers in Windows Server 2016 Datacenter, version 1607.
-
Proper sharing of directories on the Windows host can solve this issue.