How to extend an existing docker image? How to extend an existing docker image? docker docker

How to extend an existing docker image?


Simply extend it using a Dockerfile that start with

FROM dockerfile/elasticsearch

and install marvel or ssh-server or whatever you need. Then, end with the correct command to start your services. You can use supervisor to start multple services, see Run a service automatically in a docker container for more info on that.


If you don't mind using docker-compose, what I usually do is to add a first section for the base image you plan to reuse, and then use that image as the base in the rest of the services' Dockerfiles, something along the lines of:

---version: '2'services:    base:        build: ./images/base    collector:         build: ./images/collector

Then, in images/collector/Dockerfile, and since my project is called webtrack, I'd type

FROM webtrack_base...

And now it's done!


Update August 2016

Having found very little current information on how to do this with latest versions of ElasticSearch (2.3.5 for example), Kibana (4.5.3) and Marvel & Sense plugins, I opted to take the steeper path and write my own image.

Please find the source code (Dockerfile) and README here

FROM java:jre-alpineMAINTAINER arcseldon <arcseldon@gmail.com>ENV ES_VERSION=2.3.5 \    KIBANA_VERSION=4.5.3RUN apk add --quiet --no-progress --no-cache nodejs \  && adduser -D elasticsearchUSER elasticsearchWORKDIR /home/elasticsearchRUN wget -q -O - http://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz \ |  tar -zx \ && mv elasticsearch-${ES_VERSION} elasticsearch \ && wget -q -O - http://download.elastic.co/kibana/kibana/kibana-${KIBANA_VERSION}-linux-x64.tar.gz \ |  tar -zx \ && mv kibana-${KIBANA_VERSION}-linux-x64 kibana \ && rm -f kibana/node/bin/node kibana/node/bin/npm \ && ln -s $(which node) kibana/node/bin/node \ && ln -s $(which npm) kibana/node/bin/npm \ && ./elasticsearch/bin/plugin install license \ && ./elasticsearch/bin/plugin install marvel-agent \ && ./kibana/bin/kibana plugin --install elasticsearch/marvel/latest \ && ./kibana/bin/kibana plugin --install elastic/sense CMD elasticsearch/bin/elasticsearch --es.logger.level=OFF --network.host=0.0.0.0 & kibana/bin/kibana -QEXPOSE 9200 5601

If you just want the pre-built image then please do:

docker pull arcseldon/elasticsearch-kibana-marvel-sense

You can visit the repository on hub.docker.com here

Usage:

docker run -d -p 9200:9200 -p 5601:5601 arcseldon/elasticsearch-kibana-marvel-sense

You can connect to Elasticsearch with http://localhost:9200 and its Kibana front-end with http://localhost:5601.

You can connect to Marvel with http://localhost:5601/app/marvel and Sense with http://localhost:5601/app/sense

Hope this helps others and saves some time!