Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Feature request: set default machine name arg #1694

Closed
justingosan opened this issue Aug 13, 2015 · 8 comments
Closed

Feature request: set default machine name arg #1694

justingosan opened this issue Aug 13, 2015 · 8 comments

Comments

@justingosan
Copy link

This makes sense coming from boot2docker where we only work with a single vm instance and thus only do boot2docker ip, boot2docker ssh, etc

Maybe it can be the static default machine that the installer creates when migrating from boot2docker?

Or perhaps a command-line docker-machine set-default <name>?

Or maybe a new env var $MACHINE_DEFAULT_NAME

Let me know your thoughts. Thanks!

@kudos
Copy link

kudos commented Aug 13, 2015

It actually already has a concept of the active Docker vm based on which one you've exported env variables for.

@ehazlett
Copy link
Contributor

We used to do this but it proved a lot of work and potential problems as a feature of Machine is multiple machine management. We removed it for those reasons. Thanks for the feedback!

@justingosan
Copy link
Author

I see. Thanks for the info!

On Sat, 15 Aug 2015 3:26 am Evan Hazlett notifications@github.com wrote:

We used to do this but it proved a lot of work and potential problems as a
feature of Machine is multiple machine management. We removed it for those
reasons. Thanks for the feedback!


Reply to this email directly or view it on GitHub
#1694 (comment).

@mhart
Copy link

mhart commented Aug 31, 2015

@ehazlett would you be able to go into more detail on why you closed this?

It's really redundant to have docker-machine error out on these commands when you actually only have one machine – it's not particularly good UX at the moment IMO.

It's the same as if ls required an argument instead of defaulting to the current directory (and insert any other CLI command in its place).

Whether it can just figure out the name automatically, or it just reads it from a config you provide that provides a default machine name, it would certainly be much more usable with this feature and save a lot of keystrokes (and users forgetting that they have to provide a name, and trying to remember what that name was, etc)

@nathanleclaire
Copy link
Contributor

@mhart and others interested I filed an issue about a potential fix here: #1783

@inadarei
Copy link

FWIW, I agree that reasonable defaults always make for better UX, but for the lack of such defaults in the current version of the Docker Machine CLI, this is what I did to maintain my relative sanity, in case it's helpful to anybody:

alias dm-ssh='docker-machine ssh `docker-machine active`'
alias dm-ip='docker-machine ip `docker-machine active`'
alias dm-env='docker-machine env `docker-machine active`'
alias dm-inspect='docker-machine inspect `docker-machine active`'
alias dm-config='docker-machine config `docker-machine active`'

@mattfysh
Copy link

thanks @inadarei!

@arikw
Copy link

arikw commented Oct 20, 2019

I've create this bash script called "dm" that injects the default docker machine name into commands that are supported by the script.

The default machine name is taken from DOCKER_MACHINE_NAME env variable.
Usage example:

dm ssh

This will run docker-machine ssh $DOCKER_MACHINE_NAME

The supported commands are config, env, inspect, ip, kill, provision, regenerate-certs, restart, scp, ssh, start, status, stop and upgrade

The script will not inject the default machine name if a supported command is not used as the first arguments or if there's a use of an existing machine name in the command.
This means that running dm ssh dev, will run docker-machine ssh dev as usual without the usage of DOCKER_MACHINE_NAME env variable.

You can add --explain as last parameter to print the actual command that the script runs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants