11

I have created a docker-machine with my user account permission in Window 10.

By command:
C:\Users\my_name>docker-machine create -d "virtualbox" haha

However, I got a problem on removing them via CMD run as Administrator.

C:\WINDOWS\system32>docker-machine rm haha
About to remove haha
WARNING: This action will delete both local reference and remote instance.
Are you sure? (y/n): y
Error removing host "haha": C:\Program Files\Oracle\VirtualBox\VBoxManage.exe unregistervm --delete haha failed:
0%...10%...20%...
Progress state: VBOX_E_FILE_ERROR
VBoxManage.exe: error: Machine delete failed
VBoxManage.exe: error: Could not delete the medium storage unit 'C:\Users\Beetle\.docker\machine\machines\haha\disk.vmdk' (VERR_SHARING_VIOLATION)
VBoxManage.exe: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleUnregisterVM(struct HandlerArg *)" at line 165 of file VBoxManageMisc.cpp


C:\WINDOWS\system32>docker-machine ls
NAME   ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER   ERRORS
haha            virtualbox   Timeout

Although I found out that this is a permission problem, which is a machine created by an user cannot be deleted by an admin in Windows 10.

How can I remove a machine created by docker-machine (with user right level) with admin right in Windows 10 ?

Thanks for your time.

6
  • "sharing violation" does not look like a permission problem. It's rather that the file is in use. Isn't the VM running? Jul 23, 2018 at 12:18
  • Weather the VM is on or off, the CMD (run as administrator) can only show all docker-machine status as timeout. Jul 24, 2018 at 2:04
  • I do not know internals of Docker. But you will for sure have problems deleting data of one account from another account. + Anyway, you didn't really answer my question. I was asking about rm, not ls. Jul 24, 2018 at 5:00
  • I have tested once for 'rm'. 1. While the VM is on, cmd (run as user) can delete the machine; cmd (run as admin) cannot remove it. 2. While the VM is off, both an remove the machine. It seem some user data is protected while the MV is running. After this test, my question can be solved, it seem i have to stop the machine by user permission, before other action. Thx, Martin :) Jul 24, 2018 at 15:13
  • @ChunToLam If you have found a solution to your problem, you should post it as an answer here. It will likely be useful to other people who run into the same issue.
    – Tashus
    Aug 20, 2018 at 15:42

2 Answers 2

11

The following command will delete completely the Docker-Machine.

docker-machine rm ^Machine_Name^
7

so after a bit of research it's a bit more complicated but we can start with killing the docker machine:

$ docker-machine kill docker_machine_name

Then once it runs it's process we can do docker-machine ls and see it's stopped:

 NAME              ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS 

docker_machine_name   -        virtualbox   Stopped

So when that is finished we actually need to navigate to where the docker machine's are stored on our local machine. We can do so by going to this path, I have windows so this may be different for mac and linux users, the path is as follows:

C:\Users\user_name\.docker\machine\machines

And as a directory we should see docker_machine_name or the docker machine that was created. Just delete it and it's gone. If we do

$ docker-machine ls

We should see that the machine we wanted to delete is gone. Hope this helped.

3
  • Well, it doesn't really remove the machine completely. As when I try to create machine with same name again, it gives an error: docker-machine create --driver virtualbox dockervm (dockervm) Creating VirtualBox VM... (dockervm) Creating SSH key... Error creating machine: Error in driver during machine creation: /usr/local/bin/VBoxManage storagectl dockervm --name SATA --add sata --hostiocache on failed: VBoxManage: error: Storage controller named 'SATA' already exists VBoxManage: error: Details: code VBOX_E_OBJECT_IN_USE (0x80bb000c), Feb 23, 2021 at 14:06
  • @akm well I don't know if you downvoted but it clearly shows for Windows, if you have an Ubuntu issue then I would have sought out an Ubuntu solution. All it is, is basically removing the physically stored file so it does a "hard clean" of the docker environment. I also do not know what version of Ubuntu you would be using. I think the best response would have been listing a comment with your details and what you wanted help with instead of automatically looking to downvote an answer. Also, to repeat, the question asked was in the context to a Window's environment. Aug 13, 2021 at 8:15
  • thanks for the suggestion! I agree that this is for windows, I was primarily tryin on mac and I realized later that I posted logs from mac but I did try it on windows machine as well and still bumped into similar issues. But, I never downvoted your solution anyway! Sep 18, 2021 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.