简体   繁体   中英

Multistage docker build with no-cache

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;"]

--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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM