forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker image to grab the ip used by docker (eclipse-che#1891)
Change-Id: Id781e34c99f14c87909197b99969d645268e62d3 Signed-off-by: Florent BENOIT <fbenoit@codenvy.com>
- Loading branch information
1 parent
4d0b45f
commit 1af2045
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2016 Codenvy, S.A. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
# To build, in this directory: | ||
# `docker build -t codenvy/che-ip .` | ||
# | ||
# To use it: | ||
# `docker run --rm --net=host codenvy/che-ip` | ||
|
||
FROM alpine:3.4 | ||
|
||
ADD getip.sh /bin/getip.sh | ||
|
||
CMD /bin/getip.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
# Copyright (c) 2012-2016 Codenvy, S.A., Red Hat, Inc | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
|
||
|
||
# return true if system is using boot2docker | ||
is_boot2docker() { | ||
if uname -r | grep -q 'boot2docker'; then | ||
return 0 | ||
else | ||
return 1 | ||
fi | ||
} | ||
|
||
# network interface to use to grab local ip | ||
NETWORK_IF="eth0" | ||
if is_boot2docker; then | ||
NETWORK_IF="eth1" | ||
fi | ||
|
||
# grab ip from the following command | ||
ip a show "${NETWORK_IF}" | \ | ||
grep 'inet ' | \ | ||
cut -d/ -f1 | \ | ||
awk '{print $2}' | ||
|