Change Docker machine location - Windows

后端 未结 12 1229
执笔经年
执笔经年 2020-12-02 05:08

I am using docker toolbox on Windows 7 to run docker. (docker version 1.9.1)

As it turns out, the docker machine creates its VM at C:\\Users\\username\\.docker\\mach

相关标签:
12条回答
  • 2020-12-02 05:29

    I use windows 10 and Docker desktop (community) Version 2.0.0.0, I want to move vhdx file to another Drive.

    Right click over Docker Desktop -> Settings then the Docker Desktop UI will open go to Advance -> Disk image location just change the path to new destination, the whole process was smooth and fast for me - it's automatically copy the vhdx file from original path to new path restart docker and all work as expected  

    0 讨论(0)
  • 2020-12-02 05:33

    Since 2015, there is now (June 2017) Hyper-V, which allows you to define where you want your VHDX files:

    See Docker for Windows 1.13.0, 2017-01-19 (stable):

    VHDX file containing images and non-host mounted volumes can be moved (using “advanced” tab in the UI)

    That will modify the %APPDATA%\Docker\settings.json with a line:

    "MobyVhdPathOverride":"C:\\Users\\Public\\Documents\\Hyper-V\\New folder\\MobyLinuxVM.vhdx"
    

    See this thread for more.


    Original answer

    Currently 2015 , docker-machine forces the use of %USERPROFILE%:
    See libmachine/mcnutils/utils.go#L17-L25

    As commented in issue 499:

    In the meantime, how will users be able to specify where the .docker/machine/* files are stored?

    you can by specifying --storage-path on the command line or using the environment variable MACHINE_STORAGE_PATH.

    (You can see it implemented in PR 1941)

    Joost Den Boer points out in the comments

    Just tried '-s <path>' on a Mac and it seems to work fine.
    What might not be obvious is that the path option goes before the command.
    Running "docker-machine -s /Volumes/other/location' create --driver=virtualbox" created a new VirtualBox image at the other location.

    0 讨论(0)
  • 2020-12-02 05:34

    I have had a bit of trouble with any of the solutions above but this is what worked for me:

    • define the MACHINE_STORAGE_PATH environment variable to point to your desired directory/folder.
    • Install docker-toolbox as normal, if this works for you then fine, but for me it was still installing inside .docker directory.
    • To fix this I have then stopped and removed the default machine that was created along with .docker folder from the Users directory.
    • Edited the start.sh script and added the line at the top:

    e.g.

    export MACHINE_STORAGE_PATH=D:\\Docker
    
    • Run the Docker Quickstart Terminal Shortcut, which rebuilt the default machine inside the desired folder
    0 讨论(0)
  • 2020-12-02 05:35

    This is what worked perfectly for me on Windows 7:

    1. Setup the MACHINE_STORAGE_PATH environment variable as the root of the location you want to use for the Docker machines/VMs, cache, etc.
    2. Install Docker Toolbox
    3. Run Docker Quickstart Terminal

    Docker Toolbox will now create all the files at the location pointed at by MACHINE_STORAGE_PATH.

    UPDATE:

    Note that creating a new VM with the new storage path is not ideal, as the Docker Quickstart Terminal scripts don't seem to work with anything not named "default".

    If you've already got a VM sitting in the C: drive, then the simplest thing to do would be to go to Oracle VirtualBox and delete the "default" VM, uninstall Docker Toolbox, delete C:\Users\<username>.docker\, and then follow the 3 steps above.

    Note: uninstalling and reinstalling Docker Toolbox may not be required. But I haven't tested without it.

    Update

    To move Docker certificates also, set the DOCKER_CERT_PATH variable to point to the path of the new drive. Thanks to @Nutle for the tip.

    0 讨论(0)
  • 2020-12-02 05:35

    I found lots of these answers were out of data, at least they did not work in my environment: win10 PRO, docker desktop community 2.0.0.3. Finally, I resolved this problem by this method:

    1. uninstall docker

    2. open Hyper-V manager (press WIN key and then enter "Hyper")

    3. Change the default virtual hard disk locations in the Hyper-V settings (not on the VM settings) and confirm

    4. install docker

    5. check the disk image location in advanced options of docker settings

    0 讨论(0)
  • 2020-12-02 05:37

    Create file called c:\programdata\docker\config\daemon.json with content below where e:\images is location where do you want to store all you images etc. restart docker.

    { "graph": "e:\\images" }

    This Worked like a charm

    Reference - https://forums.docker.com/t/where-are-images-stored/9794/11

    0 讨论(0)
提交回复
热议问题