0

I have a multistage Dockerfile which is like below. When one of the image referred in the Dockerfile got updated, how to make sure latest versions are pulled again/always pulled while building image based on this Dockerfile. Running docker build command with --no-cache is still referring older versions of image but not actually pulling latest from docker registry.

docker build --no-cache -t test_deploy -f Dockerfile
FROM myreg.abc.com/testing_node:latest AS INITIMG
....
....
RUN npm install
RUN npm run build

FROM myreg.abc.com/testing_nginx:latest

COPY --from=INITIMG /sourcecode/build/ /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
Revanth
  • 299
  • 5
  • 13

1 Answers1

3

--no-cache tells docker not to re-use cached layers. It does not pull images if they are already existing locally. You can either docker pull myreg.abc.com/testing_node:latest before building or, more conveniently, also add --pull when calling docker build.

See https://docs.docker.com/engine/reference/commandline/build/#options

wwerner
  • 4,227
  • 1
  • 21
  • 39