Machine: Feature request: set default machine name arg

Created on 13 Aug 2015  Â·  8Comments  Â·  Source: docker/machine

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!

Most helpful comment

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`'

All 8 comments

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

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!

I see. Thanks for the info!

On Sat, 15 Aug 2015 3:26 am Evan Hazlett [email protected] 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
https://github.com/docker/machine/issues/1694#issuecomment-131214640.

@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)

@mhart and others interested I filed an issue about a potential fix here: https://github.com/docker/machine/issues/1783

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`'

thanks @inadarei!

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

diver-sity picture diver-sity  Â·  4Comments

jrz picture jrz  Â·  5Comments

pschultz picture pschultz  Â·  3Comments

BretFisher picture BretFisher  Â·  5Comments

rossbachp picture rossbachp  Â·  4Comments