Joey Pablo
Joey Pablo

Reputation: 327

Is it possible to create a docker image whitout OS?

To install my microservice binaries I need a centos. And since I have 20 microservice I'm trying to find a way to optimize the images size so I'm wondering if there's a way to create a docker image without os and at the moment of deployment Docker takes the OS Layer from cache to put it in all the images.. I'm a beginner so I don't know if I'm clear in my statements ?

Upvotes: 2

Views: 411

Answers (1)

astef
astef

Reputation: 9498

Yes, look at the scratch keyword (docs):

You can use Docker’s reserved, minimal image, scratch, as a starting point for building containers.

Also you may find useful using multi-stage builds.

An example:

FROM scratch
ADD hello /

FROM fedora
RUN yum -y update && yum clean all
RUN yum -y install nginx

Upvotes: 1

Related Questions