Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker build --no-cache=true still builds with cache?

Tags:

docker

caching

I build an image: Dockerfile:

FROM centos:7

build command:

$ docker build -t my-image:1.0 .

Now I make a second image (which is based on the original dockerfile) Dockerfile:

FROM centos:7
RUN yum install -y mysql

I build with the --no-cache option on true

$ docker build --no-cache=true -t my-image:1.1 .

Sending build context to Docker daemon 2.048 kB
Step 1 : FROM centos:7
 ---> 970633036444
Step 2 : xx

it seems to use the cache. And also when I try to delete my-image:1.0:

docker rmi 970633036444
Error response from daemon: conflict: unable to delete 970633036444 (cannot be forced) - image has dependent child images

What am I doing wrong?

like image 592
DenCowboy Avatar asked Feb 28 '26 23:02

DenCowboy


1 Answers

It uses the docker centos7 image downloaded from Docker Hub.

That will always be the case, cache or no cache.
The --no-cache would apply to the directive/step after FROM.

like image 120
VonC Avatar answered Mar 03 '26 12:03

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!