Sharing Windows Folders for Containers

Huseyin Elci
Analytics Vidhya
Published in
3 min readDec 22, 2020

--

Docker users know, when you delete or come off from a container, you made all the changes on the container are also removed. This made all the changes must be protecting and saving before deleting or coming off. You should transfer your changes to a safe place to your cloud or your local.
Docker containers are completely isolated from Windows or MacOS systems. If you want to have configuration files or other assets remain persistent, or all the changes must be protected, for this try mounting Windows folders on containers..

Let’s get started then. You must follow these steps to make setting:

  1. Setting
  2. General
  3. Resource

Setting

Docker Desktop menu allows you to configure your Docker settings such as installation, updates, version channels, Docker Hub login, and more. We have to go Setting too.

Open the Docker Desktop menu by clicking the Docker icon in the Notifications area and select Settings to open the Settings dialog:

General

On the General tab of the Settings dialog, you can configure when to start or update Docker. (I will not talk about them as they are not the subject of this post.) We have to do the first settıng here.

Attention:
The File sharing tab is only available in Hyper-V mode, because in WSL 2 mode and Windows container mode all files are automatically shared by Windows.

Resources

The Resources tab allows you to configure CPU, memory, disk, proxies, network, and other resources. Different settings are available for configuration depending on whether you are using Linux containers in WSL 2 mode, Linux containers in Hyper-V mode, or Windows containers.

You should use ‘File sharing’ to allow local directories on Windows to be shared with Linux containers. This is especially useful for editing source code in an IDE on the host while running and testing the code in a container. ?Note that configuring file sharing is not necessary for Windows containers, only Linux containers. If a directory is not shared with a Linux container you may get a file not found or cannot start service errors at runtime.

File share settings are:
Click + and navigate to the directory you want to add for adding your directory.
Apply & Restart makes the directory available to containers using Docker’s bind mount (-v) feature.

That’s it.

If you want additional information for sharing or advanced settings please visit Docker documentary. Click it.

--

--