You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to achieve the Holy Grail of passing the container the port dynamically assigned by Docker as an environment variable.
The idea was to mount a volume containing the and then parse the properties with sed at the entrypoint.
However, the file is written after the container is fully started, therefore it's not there when it is expected (I wouldn't mind adding a short sleep before the sed).
I understand it's not that easy, as the PortMapping.PropertyWriteHelper will need a refactor to only write the dynamicProperties added in the callback.
If you think this is valuable and feasible (and I think it is) and you give me some suggestions about the refactor, I could submit a merge request myself.
Thanks a lot.
Info
docker-maven-plugin version : v0.44.0
Maven version (mvn -v) : Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Docker version : Docker version 26.1.3, build b72abbb
If it's a bug, how to reproduce : N/A
If it's a feature request, what is your use case : passing dynamic port to Apache Kafka container (KAFKA_ADVERTISED_LISTENERS), other services also have this need
Sample project : N/A
The text was updated successfully, but these errors were encountered:
Description
I was trying to achieve the Holy Grail of passing the container the port dynamically assigned by Docker as an environment variable.
The idea was to mount a volume containing the and then parse the properties with
sed
at the entrypoint.However, the file is written after the container is fully started, therefore it's not there when it is expected (I wouldn't mind adding a short
sleep
before thesed
).Looking at the source code, the writing currently happens here: https://github.com/fabric8io/docker-maven-plugin/blob/master/src/main/java/io/fabric8/maven/docker/StartMojo.java#L180
And my suggestion is to move it here: https://github.com/fabric8io/docker-maven-plugin/blob/master/src/main/java/io/fabric8/maven/docker/StartMojo.java#L302
I understand it's not that easy, as the
PortMapping.PropertyWriteHelper
will need a refactor to only write thedynamicProperties
added in the callback.If you think this is valuable and feasible (and I think it is) and you give me some suggestions about the refactor, I could submit a merge request myself.
Thanks a lot.
Info
mvn -v
) : Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)KAFKA_ADVERTISED_LISTENERS
), other services also have this needThe text was updated successfully, but these errors were encountered: