Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenShift 3.1 - Prevent Docker from caching curl resource

I have this curl command in my Dockerfile:

RUN curl -H 'Cache-Control: no-cache' -f ${NEXUS_URL}${ARTIFACT_PATH}-${ARTIFACT_VERSION}.war?nocache=true -o $JBOSS_HOME/standalone/deployments/ROOT.war

The first time I ran it I could see the download information. However after that it seems to be caching the remote resource and thus, not updating it anymore:

Step 6 : RUN curl -H 'Cache-Control: no-cache' -f ${NEXUS_URL}${ARTIFACT_PATH}-${ARTIFACT_VERSION}.war?nocache=true -o $JBOSS_HOME/standalone/deployments/ROOT.war
30   ---> Using cache
31   ---> be50412bf6c3

How could I prevent this?

like image 791
codependent Avatar asked May 13 '16 10:05

codependent


People also ask

How do I stop docker from caching?

Disabling caching You can do so by passing two arguments to docker build : --pull : This pulls the latest version of the base Docker image, instead of using the locally cached one. --no-cache : This ensures all additional layers in the Dockerfile get rebuilt from scratch, instead of relying on the layer cache.

What is leverage caching in Docker?

Leverage build cache As each instruction is examined, Docker looks for an existing image in its cache that it can reuse, rather than creating a new (duplicate) image. If you do not want to use the cache at all, you can use the --no-cache=true option on the docker build command.

How do I start a service in a Docker container?

Run Docker Container as a Service Docker team recommends to use cross-platform built-in restart policy for running container as a service. For this, configure your docker service to start on system boot and simply add parameter --restart unless-stopped to the docker run command that starts YouTrack.

Which of the below OS can run Docker?

The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.


Video Answer


1 Answers

According to the OpenShift docs (https://docs.openshift.com/enterprise/3.1/dev_guide/builds.html#no-cache) you can force builds to not be cached using the following syntax:

strategy:
  type: "Docker"
  dockerStrategy:
    noCache: true

This will mean that no steps are cached, which will make your builds slower but will mean you have the correct artifact version in your build.

like image 99
joelnb Avatar answered Sep 24 '22 14:09

joelnb