Change Docker machine location - Windows

后端 未结 12 1236
执笔经年
执笔经年 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:14

    I could not get the MACHINE_STORAGE_PATH environment variable method working. It kept complaining about missing certificates when first initialising the machine. Still on Windows 7 so have to use docker-toolbox.

    I got around the issue by:

    1. Uninstalling Docker Toolbox and restarting machine
    2. Open up Administrator prompt (Find command prompt, hold shift, choose "Run As Administrator")
    3. Deleting .docker from %USERPROFILE%: rmdir /S %USERPROFILE%.docker
    4. Create folder called .docker elsewhere: mkdir a:\.docker
    5. mklink /J %USERPROFILE%.docker a:\.docker
    6. Close Admin command prompt
    7. Reinstall Docker Toolbox
    8. Use the Docker Quickstart Terminal link to bootstrap everything.
    9. Kitematic can be opened now too (though I had to choose the "Use Virtual Box" option on first error.
    0 讨论(0)
  • 2020-12-02 05:18

    Simply use the VirtualBox graphic interface to relocate the file disk.vmdk:

    1. Copy file C:\Users\{myUsername}\.docker\machine\machines\default\disk.vmdk into another folder, say F:\docker-image\.
    2. Open VirtualBox, select default VM and open Settings.
    3. Open Storage, select current disk.vmdk and release it (or delete it).
    4. Click on Choose Virtual Hard Disk File... and search for copied file in F:\docker-image\
    5. A Warning occurs: VirtualBox complains of old VM UID then go to menu File, select Virtual Media Manager... and release or remove old disk.vmdk
    6. Retry 4., it's done!
    7. If required by your environment then do the relocation also for boot2docker.iso, Snapshot Folder, Video Capture.
    0 讨论(0)
  • 2020-12-02 05:20

    This answer is for people using Docker Toolbox (Windows 10 Home Build 1909, You can follow below steps for docker installation and then location change. I am not adding any images)

    Install Docker Toolkit and VM must be installed with Admin Privileges after the installation of docker toolkit (*because Docker Toolkit also installs VM but it's of lower version and creates a problem with other iso files, u can uncheck also, in that case, *). Now we have to change the location of disk.vmdk and update the new location in VM.

    • Install Docker Toolbox from here. Follow the instructions provided
    • Now Download Virtual Machine v6+
    • Install Virtual Machine as Administrator (By Right-clicking and selecting there)
    • Goto place where your VirtualBox.exe(Not the installer) is present and right-click on it (you can find from the shortcut created on your Desktop)
    • goto properties --> compatibility --> change setting for all users --> select run this program as administrator
    • Now close the VM if it's running and run the Kitematic, If it fails (it will probably) then select option provided related to VM (only 2 options are there)
    • This time it will work, now close it

    Changing the Location where Images will be downloaded

    • open your VM and close a newly running image default (right-click -> close --> power off)
    • copy paste your disk.vmdk file (for me it's present at C:\Users\Dell\.docker\machine\machines\default\disk.vmdk) to a place where you want to store your images that you download (basically disk.vmdk is what will grow in size when you are using docker)
    • Now we need to tell the VM also about this change
    • Right-click default image and goto settings
    • Select Storage
    • remove disk.vmdk attachment by right-clicking --> remove (that was the older path binded disk.vmdk)
    • click on file --> virtual media manager and remove disk.vmdk from here also (Now VM don't know if such a disk.vmdk thing exsists)
    • Right-click default image --> storage --> add hard disk (this option is just above that iso image)
    • Now select that disk.vmdk that you have pasted somewhere
    • Now run your docker cli and then run this command docker run hello-world
    • If no error is there then it's all done
    • You can verify size by checking the sizes of those two vmdk disks and then pulling some new images



    I have written a very descriptive answer starting from installation because I did face some issues and so wanted to make it highly straight forward for the others.
    You can delete your disk.vmdk disk (older one) from your C drive if you want to

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

    Put these two commands when running docker quick start terminal.

    I suppose that your new location is "D:\docker" and your new machine name is "docker1"

    export MACHINE_STORAGE_PATH=D:\\docker
    
    docker-machine create --driver=virtualbox docker1
    

    This should create a new machine with specified name in your new location.

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

    You can move .docker directory to another drive and create a junction point to it.

    Please note that regular shortcut will not work.

    For example:

    Move .docker directory from C:\Users\username to D:\

    and run:

    C:\Users\username>mklink /j .docker D:\.docker
    Junction created for .docker <<===>> D:\.docker
    
    0 讨论(0)
  • 2020-12-02 05:29

    These answers are out of date, as of the latest release. The location is configurable in the Settings user interface.

    https://github.com/docker/for-win/issues/333

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