Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker:start wait on tcp port always failing #1234

Open
chanjarster opened this issue Jun 29, 2019 · 8 comments
Open

docker:start wait on tcp port always failing #1234

chanjarster opened this issue Jun 29, 2019 · 8 comments

Comments

@chanjarster
Copy link

Description

Using below configuration:

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>me.chanjar</groupId>
  <artifactId>dmp-test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>0.30.0</version>
        <configuration>
          <images>
            <image>
              <name>postgres</name>
              <alias>postgres</alias>
              <run>
                <env>
                  <POSTGRES_DB>saga</POSTGRES_DB>
                  <POSTGRES_USER>saga</POSTGRES_USER>
                  <POSTGRES_PASSWORD>password</POSTGRES_PASSWORD>
                </env>
                <wait>
                  <log>database system is ready to accept connections</log>
                  <tcp>
                    <ports>
                      <port>5432</port>
                    </ports>
                  </tcp>
                  <time>60000</time>
                </wait>
                <ports>
                  <port>postgres.port:5432</port>
                </ports>
              </run>
            </image>
          </images>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

mvn docker:start got error:

[INFO] DOCKER> [postgres:latest] "postgres": Start container b76c2d9ed4cc
[INFO] DOCKER> [postgres:latest] "postgres": Network mode: default
[INFO] DOCKER> [postgres:latest] "postgres": Waiting for ports [5432] directly on container with IP (null).
[ERROR] DOCKER> Error occurred during container startup, shutting down...
[INFO] DOCKER> Pattern 'database system is ready to accept connections' matched for container b76c2d9ed4cc
[INFO] DOCKER> [postgres:latest] "postgres": Stop and removed container b76c2d9ed4cc after 0 ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  18.610 s
[INFO] Finished at: 2019-06-29T03:07:40Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.30.0:start (default-cli) on project dmp-test: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.30.0:start failed: hostname can't be null -> [Help 1]

If downgrade d-m-p to 0.28.0 everything goes fine.

Info

  • d-m-p version : 0.30.0
  • Maven version (mvn -v) :
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T18:41:47Z)
Maven home: /home/ubuntu/maven
Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-52-generic", arch: "amd64", family: "unix"
  • Docker version : 18.09.6
@chanjarster chanjarster changed the title docker:start wait on tcp port not working docker:start wait on tcp port always failing Jun 29, 2019
@amoriarty
Copy link

Hi,
It take me all morning figuring out how to solve this issue.
Finally the solution I’ve found is to change the tcp mode in my configuration to mapped.
However I’m on the 0.29.0 version and not sure it will work on the latest.
Also, I’m still thinking there’s a bug here and my solution is more of a hack than a real way to solve this issue.

@kieranshaw
Copy link
Contributor

Found a potentially better fix.

The problem is with:

if (networkMode == null || networkMode.isEmpty() || "bridge".equals(networkMode)) {

If the network mode on the image is not set, it acts as the default, which is bridge. However, the actual string networkMode is "default", not "bridge", so it doesn't fall into the right block to get the right hostname/ip.

So fix for now is to explicitly set the network mode to bridge in your image.

@WillemJiang
Copy link

I hit this issue with 0.31.0 today.
It looks like we need to release new version of docker plugin to pick up the fix.

@rhuss
Copy link
Collaborator

rhuss commented Nov 21, 2019

@WillemJiang could you try with the latest snapshot release ? I just pushed a 0.31-SNAPSHOT to Maven central.

I'm planning a release for the weekend, so would be good to know if the issue here would be fixed with it.

@WillemJiang
Copy link

WillemJiang commented Nov 21, 2019

@rhuss I just ran the test with the 0.31-SNAPSHOT(by building the source on my box, as I didn't find the snapshot link from maven central), the test passed on my project without any issue.
I'm looking forward to the new release.

@jakub-bochenski
Copy link
Contributor

This is still happening to me on 0.31 as well as 0.33

@JulienBe
Copy link

JulienBe commented Sep 18, 2020

Same for me on 0.34, on a mac. Network is specified as bridge.

Most probably related to this: https://docs.docker.com/docker-for-mac/networking/#there-is-no-docker0-bridge-on-macos

Very new to macOS, still digging

@kishore25kumar
Copy link

I am facing the same issue on 0.40.1 version. Is there a solution for this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants