Can we create a docker image using docker file with out source image (OS) i.e
FROM rhel
We don't want base image(centos or rhel) in all our application docker images. we want to separate base image(centos or rhel) and application images and link them during run time. Is it possible?
When I am building docker image without FROM centos
or rhel
, docker complains: "provide source image before commit"
My docker file looks like this:
MAINTAINER abc
RUN mkdir /opt/cassandra
RUN cd /opt/cassandra
RUN wget http://www.interior-dsgn.com/apache/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz
RUN tar xvzf apache-cassandra-2.1.2-bin.tar.gz
RUN cd apache-cassandra-2.1.2-bin
You said "we want to separate base image(centos or rhel) and application images and link them during run time." That is essentially what FROM rhel
does, thanks to the layered file systems used by Docker.
That is, the FROM
image does not become part of your image -- it remains in a separate layer. Your new image points to that rhel
(or other FROM
'd base layer) and then adds itself on top of it at runtime.
So go ahead and use FROM
-- you'll get the behavior you wanted.
For those that find this question looking for a way to build their own base image (so you don't have to use anything as a base), you can use FROM scratch
and you should read about Creating a base image.
And, to be completely pedantic, the reason why Docker needs a FROM
and a base including a Linux distribution's root file system is that without a root file system, there is nothing. You can't even RUN mkdir /opt/cassandra
because mkdir
is a program provided by the root file system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With