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

Proposal: Add docker-machine exec #1074

Closed
perj opened this issue Apr 29, 2015 · 5 comments
Closed

Proposal: Add docker-machine exec #1074

perj opened this issue Apr 29, 2015 · 5 comments

Comments

@perj
Copy link

perj commented Apr 29, 2015

These would set the environment variables and then execute the command. E.g.

docker-machine exec mymachine docker images
docker-machine exec mymachine ./my-docker-wrapper.sh
@ghost
Copy link

ghost commented Apr 29, 2015

Sounds like this is already what ssh does?

docker-machine ssh mymachine -- ifconfig -a
docker-machine ssh mymachine -- docker info
docker-machine ssh mymachine -- "echo uname -a > test && chmod +x test && ./test"

Can you elaborate on how that would be different?

@perj
Copy link
Author

perj commented Apr 29, 2015

I don't want it to run on the docker host, I want it to run locally, but with docker setup to talk to the remote one. Basically a simpler version of

bash -c "eval $(docker-machine env mymachine);
docker images
"

I'm not so fond of changing my environment in my outermost shell, I keep forgetting I've done it, and then suddenly docker behaves differently and I'm confused.

@nathanleclaire
Copy link
Contributor

It's a little verbose, but if I want to run one-off docker commands on machines I usually use docker-machine config, which will spit out the correct docker flags for connection to a given machine:

$ docker $(docker-machine config name) info

You could also write a little shell alias like so if it's too much to type:

dkrm () {
    docker $(docker-machine config $1) "${@:2}"
}

It will point the Docker client at the machine specified by first argument, and pass through the rest to the Docker client.

Usage like:

$ dkrm devbox ps
... some containers on the machine "devbox"
$ dkrm staging ps
...some containers on the machine "staging"

Does that help?

@perj
Copy link
Author

perj commented Apr 29, 2015

I wasn't aware of that command, so thanks for that. It does help, but it's not as transparent as an exec command. E.g. difficult to use with docker-compose, fig, or any kind of wrapper script. I have one that builds the Dockerfile out of several files in the current dir and feeds it via docker build -.

I could do something like DOCKER="docker $(docker-machine config mymachine)" ./build.sh and then have : ${DOCKER:=docker} in the script. So it's workable. Not sure about docker-compose though.

@nathanleclaire
Copy link
Contributor

Heh, yeah, if you want to use docker-compose you're best off setting the proper environment variables.

tomeon pushed a commit to tomeon/machine that referenced this issue May 9, 2018
Hotfix: Parallels kernel modules are unavailable in v1.8.3
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

2 participants