Skip to content

Commit

Permalink
Make sure the Docker Host IP address is retrieved correctly when runn…
Browse files Browse the repository at this point in the history
…ing inside docker (#541)

* fix: introduce 'withFollowStream' and 'awaitCompletion' methods to await the completion of one-off command

* Fixed retrieval of Docker host IP when running inside Docker (#479)

* fix: withStdErr() is not needed - withTailAll() is not needed (default: tail=all)

* Update CHANGELOG.md
  • Loading branch information
jochenhebbrecht authored and bsideup committed Jan 12, 2018
1 parent 4e79301 commit fcb4481
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

### Fixed
- Fixed retrieval of Docker host IP when running inside Docker. ([\#479](https://github.com/testcontainers/testcontainers-java/issues/479))

## [1.5.1] - 2017-12-19

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.io.File;
import java.util.Optional;

import static java.util.concurrent.TimeUnit.SECONDS;

@Slf4j
public class DockerClientConfigUtils {

Expand All @@ -23,10 +25,13 @@ public class DockerClientConfigUtils {
cmd -> cmd.withCmd("sh", "-c", "ip route|awk '/default/ { print $3 }'"),
(client, id) -> {
try {
return client.logContainerCmd(id)
.withStdOut(true)
.exec(new LogToStringContainerCallback())
.toString();
LogToStringContainerCallback loggingCallback = new LogToStringContainerCallback();
client.logContainerCmd(id).withStdOut(true)
.withFollowStream(true)
.exec(loggingCallback)
.awaitStarted();
loggingCallback.awaitCompletion(3, SECONDS);
return loggingCallback.toString();
} catch (Exception e) {
log.warn("Can't parse the default gateway IP", e);
return null;
Expand Down

0 comments on commit fcb4481

Please sign in to comment.