u123
u123

Reputation: 16329

Understanding tomcat docker files

I am looking at the below tomcat docker file:

https://github.com/docker-library/tomcat/blob/5c8b74e495a1b63116b524407941b15eef58a7fe/8.0/jre8/Dockerfile

But should it not specify an OS as base image (e.g. Ubuntu, debian, etc.)?

I basically just need a docker file that contains ubuntu 16.x, java 8 and tomcat 8. But not really sure why I need that many lines in the above dockerfile to accomplish that.

Upvotes: 0

Views: 151

Answers (4)

cooltoad
cooltoad

Reputation: 171

Docker uses the FROM directive to indicate base images. If you traverse it along you get to see

FROM debian:stretch

on https://github.com/docker-library/buildpack-deps/blob/master/stretch/curl/Dockerfile

Upvotes: 1

yamenk
yamenk

Reputation: 51876

The reason you see so many lines in some Dockerfiles is that the image builds on a minimal base image. This is considered a very good practice in docker to keep the image small.

Ubuntu image and such are somehow large and are usually not required to achieve the end result of packaging an application.

In the tomcat image, the Dockerfile is buidling on top of the openjdk:8-jre image, which itself is built on top of a basic debian:stretch. Thus it might not be direct to install tomcat directly in the Dockerfile like you do with Ubuntu.

Upvotes: 0

Rob Lockwood-Blake
Rob Lockwood-Blake

Reputation: 5066

A Dockerfile can specify FROM using any valid Docker image. You often get a hierarchy of images, one that has the base OS installed and then children that customise the OS for running certain application types e.g. Java apps, Node apps and so on.

To work out what is in your image, you need to follow up from the hierarchy of FROM statements to get a complete picture.

From the Dockerfile you link, you can see the FROM openjdk:8-jre. This tells us that this Dockerfile builds an image based upon the :latest tag of the openjdk:8-jre image. So that means we can find the Dockerfile for that image and see that the openjdk:8-jre actually builds on the buildpack-deps:stretch-curl image, which in turn builds on the debian:stretch image.

Alternatively you can use docker history against the image e.g. docker history openjdk:8-jre to see the list of layers that the image consists of.

Upvotes: 0

Sławomir Czaja
Sławomir Czaja

Reputation: 383

Image contains tomcat APR library which needs to be compiled on the docker image. Library is not required for tomcat to run but it's recommended to have it in production as it's fast and scalable connector.

Upvotes: 0

Related Questions