Giter VIP home page Giter VIP logo

Comments (3)

khmarbaise avatar khmarbaise commented on August 15, 2024

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.

mikerimov avatar mikerimov commented on August 15, 2024

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.

warrenc5 avatar warrenc5 commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.