HomeAdvisor / Kafdrop

Kafka UI and Monitoring Tool
Apache License 2.0
400 stars 163 forks source link

Added docker support. #4

Closed zonybob closed 7 years ago

zonybob commented 7 years ago

I plan on using Kafdrop for a project I'm working, and I needed it dockerized. Figured I'd commit this back since I saw an open issue. Feel free to review, accept, reject, etc.

Uses maven-assembly to build the tar, then spotify docker-maven-plugin to build/push the docker image. I have not pushed it anywhere, as I do not have any experience pushing to dockerhub.

I built with mvn clean package assembly:single docker:build

I ran with docker run -d -p 9000:9000 -e ZOOKEEPER_CONNECT=master.mesos:2181/kafka kafdrop

When running in marathon, the memory constraint will automatically trigger JVM heap args to get set. Also, JMX should still be accessible, but you'll need to look at the randomly assigned port.

michael-pratt commented 7 years ago

Many thanks for this PR! I'm getting the following error when running the docker:build step of maven:

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.9:build (default-cli) on project kafdrop: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1] failed: Connection refused -> [Help 1]

zonybob commented 7 years ago

Oops... I guess I should have mentioned my underlying environment... 1) CentOS 7 (any Linux should be fine) 2) Docker 1.9 (anything >= 1.9 should be fine) 3) Run as a user with privileges to talk to the Docker daemon (this can be root, a user in the "docker" group, OR alternatively, you could configure Docker to listen on a TCP port such as 2375). Simplest thing IMHO is to add yourself to the docker group.

Hopefully that helps!

michael-pratt commented 7 years ago

The issue was with Docker for Mac:

https://forums.docker.com/t/spotify-docker-maven-plugin-cant-connect-to-localhost-2375/9093

Upgrading to the latest spotify plugin (0.4.13) fixes the problem.

I also had to run dos2unix on src/main/docker/kafdrop.sh as the new lines were causing some obscure docker startup issues:

https://forums.docker.com/t/standard-init-linux-go-175-exec-user-process-caused-no-such-file/20025

Otherwise it looks good. I'll merge the PR now and update the spotify plugin version after. Not sure about a good solution for the new line issue, for now I'll update the wiki to indicate how to work around it.

Thanks again for this PR, it's much appreciated!