title: Share variable in multi-stage Dockerfile: ARG before FROM not substituted
body: <p>I'm writing a multi-stage Dockerfile for the <a href="https://www.mcs.anl.gov/research/projects/darshan/" rel="noreferrer">darshan utils</a>:</p>
  
  <pre><code>ARG DARSHAN_VER=3.1.6
  
  FROM fedora:29 as build
  RUN dnf install -y \
          gcc \
          make \
          bzip2 bzip2-devel zlib zlib-devel
  RUN curl -O "ftp://ftp.mcs.anl.gov/pub/darshan/releases/darshan-${DARSHAN_VER}.tar.gz" \
      &amp;&amp; tar ...
  
  
  FROM fedora:29
  COPY --from=build "/usr/local/darshan-${DARSHAN_VER}" "/usr/local/darshan-${DARSHAN_VER}"
  ...
  </code></pre>
  
  <p>I build it with <code>docker build -t darshan-util:3.6.1 .</code> and the error I get is:</p>
  
  <pre><code>Step 5/10 : RUN curl -O "ftp://ftp.mcs.anl.gov/pub/darshan/releases/darshan-${DARSHAN_VER}.tar.gz"     &amp;&amp; tar ...
  
   ---&gt; Running in 9943cce1669c
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  ...
  curl: (78) RETR response: 550
  The command '/bin/sh -c curl -O "ftp://ftp.mcs.anl.gov/pub/darshan/releases/darshan-${DARSHAN_VER}.tar.gz"     &amp;&amp; tar ...' returned a non-zero code: 78
  </code></pre>
  
  <p>I'd like to reuse the same ARG in both stages, so that I can define a default build variable just once.
  If I duplicate ARG in both stages, just below the two FROMs, it builds correctly.</p>
  
  <p>What is the correct way to define a "global" multi-stage ARG variable with a default?</p>