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:

  • Docker and Django
  • Use Docker, Gunicorn, Nginx in django development environment but can only see nginx welcome page?
  • FeignClient call with consul service throws connection refused in docker container
  • 'Unable to revive connection’ errors when running ES in Docker container network
  • Heapster fails to get container stats from Kubelet on Kubernetes cluster
  • Docker doesn't get 100% of the CPU
  • 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?

  • How do I use docker from local to a remote machine?
  • Setting up Docker on Windows for PHP - can not find config file
  • Dockerfile not able to build on Ubuntu 14.04 but does fine on Windows 10 and Ubuntu 16.04
  • Bind to docker socket on Windows
  • how can i dynamically create a docker container from a node application
  • Docker container curl to web
  • 3 Solutions collect form web for “OpenShift 3.1 – Prevent Docker from caching curl resource”

    According to the OpenShift docs ( you can force builds to not be cached using the following syntax:

      type: "Docker"
        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.

    You can bust the cache at a specific Dockerfile instruction using ARG.

    In the Dockerfile:

    RUN git clone 

    On the command line:

    docker build -t your-image --build-arg CACHEBUST=$(date +%s) . 

    Setting CACHEBUST to the current time means that it will always be
    unique, and instructions after the ARG declaration in the Dockerfile
    won’t be cached. Note that you can also build without specifying the
    CACHEBUST build-arg, which will cause it to use the default value of 1
    and preserve the cache. This can be used to always check out fresh
    copies of git repos, pull latest SNAPSHOT dependencies, etc.



    You can use –no-cache, or –build-arg to invalidate the cache. You
    can minimize the effect of –no-cache by having a base image with all
    the cacheable commands.


    I can’t control the way docker is run, I mean I am running in a PaaS that calls my dockerfile so I can’t pass arguments in docker build

    You could try and control the content of your Dockerfile though.

    If you can re-generate the Dockerfile before letting the PaaS calling it, that would help making sure the cache is invalidated:

    sed -i 's/ROOT.war.*/ROOT.war && echo $(date)'/g' Dockerfile
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.