Reputation: 16329
I am looking at the below tomcat docker file:
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
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
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
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
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