About building image for web application

I’m new to docker. I’m trying to create image with Ubuntu, Java and Apache. What I did is I created an Image as below

FROM ubuntu:16.04
FROM jdk:8
FROM apache

My question is, is it right way to create an Image, because the images (Jdk and apache) which I got from docker hub may be built from a different Ubuntu version and I may get conflicts or they don’t have any OS installed in it or it may not behave as intended?

Please suggest a solution.


You are misusing FROM. It is not additive. You can only have one base image. Your example switches between 3 base images; it doesn’t combine them.

You probably want something like:

FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -q -y openjdk-8-jdk apache2
1 Like

In addition to what coder98103 says (which is completely correct), I generally try to separate my middle-ware from the web-server, whenever possible.

1 Like

Thanks for your reply.