Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing what was added in previous layer in docker

Tags:

docker

I'm trying to reduce the size of my docker image. In my docker file, I do this:

FROM crystal/centos
MAINTAINER crystal

ADD ./rpms/test.rpm ./rpms/ 
RUN yum -y --nogpgcheck localinstall /rpms/test.rpm 

from what I understand, the ADD command is in its own layer, and then RUN is in another layer. So after I install the rpm, how do I go about deleting the initial /rpms directory.

like image 945
Crystal Avatar asked Oct 28 '14 15:10

Crystal


1 Answers

use this technique

RUN curl http://someaddress/test.rpm &&\
    yum -y --nogpgcheck localinstall /rpms/test.rpm &&\
    rm test.rpm
like image 169
Montells Avatar answered Dec 20 '22 14:12

Montells