fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.89k stars 642 forks source link

Custom network + wait doesn't work because property is not interpolated? #1063

Open jakub-bochenski opened 6 years ago

jakub-bochenski commented 6 years ago

Description

Related to #703 but I'm not using autoCreateCustomNetworks

I can use wait with <network><mode>bridge</mode></network>, it works if I add <host>${docker.container.psb-mysql.ip}</host> to <wait>.

I can't get it to work using <mode>custom</mode>. In that case ${docker.container.psb-mysql.ip} is not defined at all. When I try to use <host>${docker.container.psb-mysql.net.psb-net.ip}</host> it seems that property is also not defined at this time.

[INFO] --- docker-maven-plugin:0.26.0:start (start) @ ps-platform ---
[INFO] DOCKER> [mysql:5.7] "psb-mysql": Start container 0e3e7ef6f9ec
[INFO] DOCKER> [mysql:5.7] "psb-mysql": Waiting for ports [3306] directly on container with IP ().
[INFO] DOCKER> [mysql:5.7] "psb-mysql": Waited on tcp port '[localhost/127.0.0.1:3306]' 5 ms
[INFO] 
[INFO] --- properties-maven-plugin:1.0.0:write-project-properties (default) @ ps-platform ---

I can see docker.container.psb-mysql.net.psb-net.ip is defined when I later dump it with write-project-properties

The only way I can get it to work is to enter the ip (172.17.0.2) directly in the pom.xml, but that is not practical.

[INFO] --- docker-maven-plugin:0.26.0:start (start) @ ps-platform ---
[INFO] DOCKER> [mysql:5.7] "psb-mysql": Start container 73be530640ab
[INFO] DOCKER> [mysql:5.7] "psb-mysql": Waiting for ports [3306] directly on container with IP (172.17.0.2).

Info

jakub-bochenski commented 6 years ago

self note: maybe I need to use the + workaround https://dmp.fabric8.io/#implicit-properties

rhuss commented 6 years ago

@jakub-bochenski yes, it could be really that the post-interpolation that we have to do when we know the ip fails because Maven already replaced the empty property with an empty string.

But it could be also something different, however you should try to prefix you property with a + if its the only part of the config value.

jakub-bochenski commented 6 years ago

@rhuss the + workaround doesn't help The log is now:

[INFO] DOCKER> [mysql:5.7] "psb-mysql": Waiting for ports [3306] directly on container with IP (+${docker.container.psb-mysql.net.psb-all.ip}).

and the check simply times out (probbably because it tries to use +${docker.container.psb-mysql.net.psb-all.ip} string as IP.

Also: is it expected that ${docker.container.psb-mysql.ip} is not defined when using custom networks? There is nothing about it in the docs

sophokles73 commented 5 years ago

I am running into the exact same problem. Waiting on a TCP port using direct mode does not work on a custom network :-(

sithmein commented 5 years ago

Same problem here. Is there anything I can help to solve it? It currently blocks us running integration tests at all. Edit: it's not just the wait that doesn't work. The variable for the container's IP address is not filled with any value at all, also for subsequent plug-ins. Edit: Using docker.container.<alias>.net.<network>.ip works in subsequent plug-ins but not in wait.

dantalian-pv commented 5 years ago

Here I've made a fix for custom network IP to be set. Maybe it also fixes this issue as well.

jakub-bochenski commented 5 years ago

@dantalian-pv why not send a PR then?

dantalian-pv commented 5 years ago

@jakub-bochenski I did. There is no feedback about my pull request, except some sonar-pr stuff, with which I don't know what to do (It shows [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project docker-maven-plugin: The preview mode, along with the 'sonar.analysis.mode' parameter, is no more supported. You should stop using this parameter. -> [Help 1]).

jakub-bochenski commented 5 years ago

This looks like an infra problem with the circleci build setup for this repo. I can't offer anything better than trying to ping @rhuss to do something about it.

jakub-bochenski commented 5 years ago

Just found a seemingly related PR merged last December https://github.com/fabric8io/docker-maven-plugin/pull/1130