Comments (3)
How do you launch the docker containers? Using docker compose? Or starting docker containers via command line or via a maven plugin?
You can of course configure the plugin to make a port assignment randomly via:
<configuration>
<randomPort>true</randomPort>
..
</configuration>
from build-helper-maven-plugin.
Ultimately I launch the docker containers via fabric8.io's docker-maven-plugin, passing in the port numbers per what's been defined here.
Rough example: (where db.port is assigned by the build-helper-maven-plugin and pulled in by properties-maven-plugin). I've left out a few properties in the docker-maven-plugin that were specific to a private container.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<executions>
<execution>
<id>load-port-properties</id>
<phase>pre-integration-test</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.build.directory}/ports.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.21.0</version>
<configuration>
<logDate>default</logDate>
<autoPull>true</autoPull>
<image>
<alias>db</alias>
<name>mysql-container-example</name>
<run>
<ports>
<port>${db.port}:3306</port>
</ports>
/.. More run options specific to the customized container we're using..../
</run>
</image>
</configuration>
<executions>
<execution>
<id>start-docker-db</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-docker-db</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
And yes, my current workaround is to make it a random port so collisions are rare.
Hope this clarifies
from build-helper-maven-plugin.
I'm on a mac - I have ipv6 off on my external interface.
networksetup -setv6off "ethernet"
I have two ports
wozza$ netstat -nlat | grep 99
tcp46 0 0 *.9900 . LISTEN
tcp4 0 0 *.9905 . LISTEN
9900 gets detected and assigned 9901
9905 never gets detected so there is always a collision when I run mvn twice
unfortunately 9905 is the jdwp dt_socket port doesn't support ipv6
Basically mvn will check the IPV6 :1 port
I can confirm this by running
mvn -Djava.net.preferIPv4Stack=true
And then neither 9900 or 9905 are incremented.
Buildhelper failed to see that those ports were already on tcp4.
https://bugs.openjdk.java.net/browse/JDK-8184770
from build-helper-maven-plugin.
Related Issues (20)
- Allow port ranges on reserve-network-port mojo
- released-version does not detect version if maven repository is not configured to look for snapshot
- The plugin does not execute with command line "mvn compile" as in the Maven Handbook. HOT 4
- Use `bsh-property` property for profile activation HOT 5
- Plugin does not honour the skip directive HOT 2
- timestamp-property setting pattern has no effect HOT 1
- Using parse-version with effective-pom generates invalid XML, adds <?xml...?> tag twice
- [RFE] attach-artifact: Add a ignoreIfMissing property to Artifact
- Quiet option for `regex-property` goal. HOT 2
- Please provide a `<skip>` option for each goal. HOT 1
- Feature request: Add version limits to released-version goal
- `regex-property` goal doesn't interpret `<replacement>` correctly, corrupting output
- Request: Capability to use goal "add-source" from the command line
- Option to override nextIncrementalVersion
- Fails the build when running using Maven 3.9.0 HOT 18
- Wrong encoding of pom file in maven central HOT 4
- Plugin should declare these Maven artifacts in `provided` scope HOT 2
- nextBuildNumber HOT 3
- Extension HOT 3
- Documentation issue with goals example HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from build-helper-maven-plugin.