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

Updated Dockerfile #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
FROM anapsix/alpine-java:8
MAINTAINER sscaling <[email protected]>
FROM openjdk:8-jre

RUN apk update && apk upgrade && apk --update add curl && rm -rf /tmp/* /var/cache/apk/*
ARG buildversion=0.14.0
ARG buildjar=jmx_prometheus_httpserver-$buildversion-jar-with-dependencies.jar

ENV VERSION 0.12.0
ENV JAR jmx_prometheus_httpserver-$VERSION-jar-with-dependencies.jar

RUN curl --insecure -L https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 -o usr/local/bin/dumb-init && chmod +x /usr/local/bin/dumb-init
ENV version $buildversion
ENV jar $buildjar
ENV SERVICE_PORT 5556
ENV CONFIG_YML /opt/jmx_exporter/config.yml
ENV JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=5555

RUN mkdir -p /opt/jmx_exporter
RUN curl -L https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/$VERSION/$JAR -o /opt/jmx_exporter/$JAR
COPY start.sh /opt/jmx_exporter/
RUN useradd -ms /bin/bash prom_exporter
RUN chown prom_exporter:prom_exporter /opt/jmx_exporter

USER prom_exporter

RUN curl -L https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/$version/$jar -o /opt/jmx_exporter/$jar
COPY config.yml /opt/jmx_exporter/

CMD ["usr/local/bin/dumb-init", "/opt/jmx_exporter/start.sh"]
CMD ["sh", "-c", "java $JVM_OPTS -jar /opt/jmx_exporter/$jar $SERVICE_PORT $CONFIG_YML" ]
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
[![Build status](https://travis-ci.com/sscaling/docker-jmx-prometheus-exporter.svg?branch=master)](https://travis-ci.com/sscaling/docker-jmx-prometheus-exporter) [![Docker Pulls](https://img.shields.io/docker/pulls/sscaling/jmx-prometheus-exporter.svg)](https://hub.docker.com/r/sscaling/jmx-prometheus-exporter)

Docker JMX exporter for Prometheus
==================================

Essentially another dockerised JMX Exporter image, this uses alpine-java and dumb-init to provide a relatively small image (approx 130Mb) and includes a released version of jmx_exporter from the [maven central repository](https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/)

Available on [Docker hub](https://hub.docker.com/r/sscaling/jmx-prometheus-exporter/)
Available on [Docker hub](https://hub.docker.com/r/reasland/jmx-prometheus-exporter/)

Building docker image
---------------------

```
docker build -t sscaling/jmx-prometheus-exporter .
docker build -t reasland/jmx-prometheus-exporter .
```

### Build Arguments

Additionally, the following build arguments can be defined

- version - default 0.14.0 - what version of the jmx_exporter http server to use (if you are going to docker push, please tag prom_jmx:$VERSION)
- jar - default jmx_prometheus_httpserver-$VERSION-jar-with-dependencies.jar - what jar file from the maven repo https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_httpserver/ to use

Running
-------

```
docker run --rm -p "5556:5556" sscaling/jmx-prometheus-exporter
docker run --rm -p "5556:5556" reasland/jmx-prometheus-exporter
```

Then you can visit the metrics endpoint: [http://127.0.0.1:5556/metrics](http://127.0.0.1:5556/metrics) (assuming docker is running on localhost)
Expand All @@ -29,7 +34,7 @@ Configuration
By default, the jmx-exporter is configured to monitor it's own metrics (as per the main repo example). However, to provide your own configuration, mount the YAML file as a volume

```
docker run --rm -p "5556:5556" -v "$PWD/config.yml:/opt/jmx_exporter/config.yml" sscaling/jmx-prometheus-exporter
docker run --rm -p "5556:5556" -v "$PWD/config.yml:/opt/jmx_exporter/config.yml" reasland/jmx-prometheus-exporter
```

The configuration options are documented: [https://github.com/prometheus/jmx_exporter](https://github.com/prometheus/jmx_exporter)
Expand Down
2 changes: 1 addition & 1 deletion docker_push
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

BASE_IMAGE="sscaling/jmx-prometheus-exporter"
BASE_IMAGE="reasland/jmx-prometheus-exporter"
IMAGE_VERSION="$1"

if [ -z "$IMAGE_VERSION" ]; then
Expand Down
15 changes: 0 additions & 15 deletions start.sh

This file was deleted.