Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Provide option to store images/containers/volumes on other drives #239

Open
SetTrend opened this issue Jun 30, 2021 · 9 comments
Labels
community_new New idea raised by a community contributor docker_desktop Improvements or additions to Docker Desktop

Comments

@SetTrend
Copy link

I'm not sure if this is a Windows peculiarity, so I first posted my feature request to the Docker for Windows issues list.

Professional Windows users tend to have more than just a single hard drive in their machines, using the second (and further) drives to store their data, while reserving the first drive (the so-called "C:" drive) for Windows and program installation (i. e., things that can easily be restored when Windows becomes inaccessible due to misconfiguration, hardware failure or whatever).

Docker currently

lacks the ability to assign a mount point for images, containers and volumes.

At this time, my system disk (C:) is full, just by being mainly filled with WSL 2 containers, volumes and images.

My D: drive, however, is ...

  1. empty
  2. larger
  3. expandable

So, I propose the following feature:

Provide a data-path option with Docker


  1. Provide a Data Path option with the Docker installer, allowing users to define a default folder for storing images, containers and volumes.

  2. Add a new Data Path parameter to docker build, docker commit, docker container create, docker create, docker run, and docker volume create:

    --data-path {destination path}


The destination path is supposed to be a directory wherein the corresponding image, container or volume will create its own, internal, private sub directory to store its data. So, if the destination directory was D:\DockerData\tmp, then an image, for example, may first create a sub directory, like D:\DockerData\tmp\03624fa1359\ to then store its data therein.


Examples:

> docker build -t fromImage --data-path D:\DockerData\nano\ .
> docker run -d --name test --data-path D:\DockerData\nano\ fromImage
> docker volume create --data-path D:\DockerData\nano\ myStorage
@odupuy
Copy link

odupuy commented Aug 13, 2021

Here is a band aid solution to select the folders

@christophermclellan
Copy link
Collaborator

Thanks for submitting your issue, we are not working on this right now but we might in future.

@mat007
Copy link
Member

mat007 commented Nov 4, 2022

There is a field in the Settings to set the location of the data folder, for Mac and Windows Hyper-V.
For historical reasons, there is no such setting for Windows WSL 2…
We have an internal ticket for adding this, but it hasn’t been prioritized yet.

@mat007
Copy link
Member

mat007 commented Jan 23, 2023

We have added a similar field in the settings for the WSL 2 data, this will be available in Docker Desktop 4.17.

@spudcz
Copy link

spudcz commented Feb 7, 2023

For me worked this solution:

For windows containers (I didn't have any image or volume yet.)

  1. Open folder %USERPROFILE%.docker
  2. Locate windows-daemon.json
  3. Add line to JSON
    "data-root": "D:\\Docker\\win",
  4. Restart docker and make sure Windows containers are on
  5. Run
    docker pull mcr.microsoft.com/windows/nanoserver:ltsc2019

After that, I can see that the image is on disk D

For linux containers I moved the wsl distribution docker-desktop-data

  1. Show wsl distros
    wsl --list -v
  2. Stop wsl if not already
    wsl --shutdown
  3. Export docker-desktop-data
    wsl --export docker-desktop-data "D:\Docker\wsl\data\docker-desktop-data.tar"
  4. Unregister distro docker-desktop-data
    wsl --unregister docker-desktop-data
  5. Import distro from new location
    wsl --import docker-desktop-data "D:\Docker\wsl\data" "D:\Docker\wsl\data\docker-desktop-data.tar" --version 2
  6. Now you can delete the exported D:\Docker\wsl\data\docker-desktop-data.tar in the location D:\Docker\wsl\data\ there is a file with name ext4.vhdx

@christophermclellan
Copy link
Collaborator

Hey @mat007 , can we close this now ?

@SetTrend
Copy link
Author

SetTrend commented Mar 30, 2023

Can we please have an extension to dockerfile FROM and the CLI to designate a target folder/drive?

The requested destination directive should be a "weak" one, so when the target folder/drive doesn't exist, the image/container shall be downloaded to the default location and a warning should be output.

@rdicroce
Copy link

@christophermclellan IMO this should not be closed because this feature still does not actually work. See docker/for-win#13269.

@C-h-e-r-r-y
Copy link

In my opinion, using a single file for containers and images is not a good solution. There should be a possibility to use different locations on different drives. Moving everything into slow HDD is not good solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_new New idea raised by a community contributor docker_desktop Improvements or additions to Docker Desktop
Projects
None yet
Development

No branches or pull requests

8 participants