Reputation: 8345
How can I rename a docker-machine
machine? I can't find it using docker-machine --help
or in the subcommand docs.
Upvotes: 21
Views: 11789
Reputation: 73
I followed the following steps for docker-compose with VirtualBox in Mac OSX
modifyvm "$OLD_MACHINE_NAME" --name "$NEW_MACHINE_NAME")
mv $OLD_MACHINE_NAME $NEW_MACHINE_NAME
I'm using the following versions: docker-machine version 0.13.0, build 9ba6da9 Virtual Box Version 5.2.6 r120293
Upvotes: 1
Reputation: 1
If you use docker toolbox to create or start docker machine ,there is a script file to config machine settings including name. Find your docker toolbox path like:c:\Program Files\Docker Toolbox. There is a script named start.sh .replace default name as your machine's name.
VM=${DOCKER_MACHINE_NAME-xxxxx}
It is better to remove your default machine files before change config. Then restart toolbox.
Upvotes: 0
Reputation: 487
Basically you have to:
/.docker/machine/machines/
)config.json
with the new name and new pathHere is a gist for VirtualBox. With this you can rename machines like this docker-machine-rename default my-default
This will only work if you are using VirtualBox. If you are using paralells driver or something else you have to replace vboxmanage ...
with the appropriate command for that driver
EDITED I updated the script after receiving feedback from @DagHøidahl
Upvotes: 14
Reputation: 842
!! WARNING: The method I used below did not work !!
In the final restart I had a client version mismatch. After closing the terminal and restarting the "Docker Quickstart Terminal" my default machine was deleted and re-created... :(
Anyway, for those who might be able point out any error in the process - I've listed it here.
Perhaps the name 'default' is reserved. For the moment I am sticking with the name 'vm' for the machine hosted in VMWare Fusion
I've posted this non-answer as a warning for anyone who might try the same and lose any containers in the default machine.
Goal: delete the default machine and rename vm to default. Then use the new machine as default
The method I used is not elegant, and [in the end] did not work for me...
docker-machine rm default
cd ~/.docker/machine/machines
mv vm default
cd default
mv vm.plist default.plist
mv vm.vmdk default.vmdk
mv vm.vmdk.lck default.vmdk.lck
mv vm.vmsd default.vmsd
mv vm.vmx default.vmx
mv vm.vmx.lck default.vmx.lck
mv vm.vmxf default.vmxf
[you need to do this yourself...]
$ docker-machine start default
Starting "default"...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run thedocker-machine env
command.
$ docker-machine env
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "172.16.41.132:2376": x509: certificate is valid for 172.16.41.131, not 172.16.41.132
You can attempt to regenerate them usingdocker-machine regenerate-certs [name]
.
Be advised that this will trigger a Docker daemon restart which will stop running containers.
$ docker-machine regenerate-certs default
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y
Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
At this point the machine worked fine... however, attempting another docker-machine restart default
produced a client version mismatch error.
After closing the terminal and restarting "Docker Quickstart Terminal" the default machine was regenerated using the virtualbox and my VMWare hosted default machine was deleted...
Upvotes: -2