Reputation: 1272
So, I am creating Dockerfile in which I am using my already existing ansible-wrok.
for instance:-
COPY run.sh /root/run.sh
RUN chmod +x /root/run.sh
RUN ansible-playbook ansible/haproxy.yml -vvvv
Above, DockerFile creates my image.
Now, if I want to add something after creating the image, lets say create a new-directory in container
RUN mkdir test
However if i again run the docker build command for creating the image it will run from scratch.
is there a way to push only modified changes in the docker Image?
Upvotes: 1
Views: 248
Reputation: 7028
As long as there aren't changes:
RUN mkdir test
in the Dockerfile
Dockerfile
) which are referenced in the preceding lineswhen running subsequent docker build
, daemon will use the cache from the previous builds of that project. If image is building from scratch, it means that one of the conditions is not satisfied.
Docker images are persisted and transported in layers. Although docker images
will show you the total size of that image, docker is smart enough to reuse the layers that are shared among multiple images - meaning - if caching works as expected your subsequent build and push should be faster than if you did it from scratch.
Upvotes: 2