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

Write portPropertyFile as soon as the container is started #1789

Open
dav-garcia opened this issue May 28, 2024 · 0 comments
Open

Write portPropertyFile as soon as the container is started #1789

dav-garcia opened this issue May 28, 2024 · 0 comments

Comments

@dav-garcia
Copy link

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 the sed).

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 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
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

1 participant