-
-
Save osteele/4809e8c6334bccfd93c286b4834df545 to your computer and use it in GitHub Desktop.
Rename docker-machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash -eu | |
#copy this in a folder from path ex: /usr/local/bin | |
#usage: docker-machine-rename default my-default | |
# From https://gist.github.com/alexproca/2324c60c86380b59001f | |
# w/ comments from eurythmia | |
OLD_MACHINE_NAME=${1:-default}; | |
NEW_MACHINE_NAME=${2:-my-default-2}; | |
STORE_PATH=$(docker-machine inspect ${OLD_MACHINE_NAME} | sed -n 's/^ *"StorePath": "\(.*\)",/\1/p') | |
mv "$STORE_PATH/machines/$OLD_MACHINE_NAME" "$STORE_PATH/machines/$NEW_MACHINE_NAME"; | |
cp "$STORE_PATH/machines/$NEW_MACHINE_NAME/config.json" "$STORE_PATH/machines/$NEW_MACHINE_NAME/config.json.bak" | |
sed -i.bak "s/${OLD_MACHINE_NAME}/${NEW_MACHINE_NAME}/g" ${STORE_PATH}/machines/${NEW_MACHINE_NAME}/config.json | |
vboxmanage modifyvm "$OLD_MACHINE_NAME" --name "$NEW_MACHINE_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment