★ wanayoo — archive 1999 https://github.com/boot2docker/boot2docker-cli/issues/310Nouvelle recherche | Portail wanayoo
Skip to content
This repository has been archived by the owner. It is now read-only.

Make `boot2docker ip` just output IP for easy use in scripts #310

Closed
beorn opened this issue Nov 8, 2014 · 4 comments
Closed

Make `boot2docker ip` just output IP for easy use in scripts #310

beorn opened this issue Nov 8, 2014 · 4 comments

Comments

@beorn
Copy link

@beorn beorn commented Nov 8, 2014

It's very useful to be able to get the boot2docker VM's IP and use it in scripts (to access docker containers that expose services on the docker host), and though there are two ways to do it now, both are convoluted and fickle:

  1. From $DOCKER_HOST:

% DOCKER_IP=echo $DOCKER_HOST | cut -d: -f2 | cut -c3-

  1. From boot2docker ip

% boot2docker ip
The VM's Host only interface IP address is: 192.168.59.103


This seems like a common use that that could be made much easier:

  1. Add a $DOCKER_IP env variable that contains the IP
  2. Make boot2docker ip just output the IP address
SvenDowideit added a commit to SvenDowideit/boot2docker-cli that referenced this issue Nov 10, 2014
add an explicit example for adding a Docker daemon parameter
@tianon
Copy link
Contributor

@tianon tianon commented Nov 11, 2014

So, this is a "clever" one where if you do echo $(boot2docker ip) it only provides the IP address, but it's caused enough confusion that I'm definitely +1 on making it just return the IP without any extra text so we stop having to explain how "clever" it is and have it instead just do what people expect it to. 😄

@beorn
Copy link
Author

@beorn beorn commented Nov 11, 2014

Hehe, yes, I didn’t know that! :) Just fixed my scripts.

Though after eating stdout, the remaining output is sent to stderr (The VM’s Host only IP address… and the blank lines), which is not very “unixy" - usually stderr is reserved for errors only, which you don’t want to ignore/silence, so it’s a bit disturbing to live with the extra (and incomplete since the IP is “eaten” by stdout) output all the time.

Also it’s a bit extraneous and arguably not a very good fit with the terseness / “silence is golden” Unix philosophy “rule": http://homepage.cs.uri.edu/~thenry/resources/unix_art/ch11s09.html
from http://homepage.cs.uri.edu/~thenry/resources/unix_art/ch01s06.html

I guess it comes down to how well you want to fit into a unix scripting world vs an interactive shell world.

On Nov 12, 2014, at 5:00 , Tianon Gravi notifications@github.com wrote:

So, this is a "clever" one where if you do echo $(boot2docker ip) it only provides the IP address, but it's caused enough confusion that I'm definitely +1 on making it just return the IP without any extra text so we stop having to explain how "clever" it is and have it instead just do what people expect it to.


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

@pirog
Copy link

@pirog pirog commented Nov 12, 2014

+1

@antonyh
Copy link

@antonyh antonyh commented Nov 18, 2014

Another workaround is to redirect stderr;

ping $(boot2docker ip 2>/dev/null)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.