You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Variables defined by ARG and ENV should be scoped to a build stage. Currently, features related to Dockerfile variables such as textDocument/definition, textDocument/documentHighlight, textDocument/hover, and textDocument/rename are all getting spanned across multiple build stages.
Renaming a variable in one build stage will cause the similarly named ones in another other build stage to be renamed and highlighting a variable will highlight all the instances in the Dockerfile when the highlighting should only be scoped to the build stage that encompasses the instruction with that variable. Similarly, hovering over a variable will incorrectly display defined values from an earlier build stage when it should be empty if that variable has never been declared in the current build stage. Also, opening a variable's definition will jump to a declaration in an earlier build stage when the lookup should only be performed in the current build stage.
The docker build output below shows how variables should be scoped to its encompassing build stage. The second RUN echo $var statement prints nothing because the variable has not been defined in the second build stage.
FROM alpine
ARG var=value
RUN echo $var
FROM alpine
RUN echo $var
$ docker build .
Sending build context to Docker daemon 86.15MB
Step 1/5 : FROM alpine
latest: Pulling from library/alpine
88286f41530e: Pull complete
Digest: sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe
Status: Downloaded newer image for alpine:latest
---> 7328f6f8b418
Step 2/5 : ARG var=value
---> Running in 2b3317a23f64
---> eb0507a9cd61
Removing intermediate container 2b3317a23f64
Step 3/5 : RUN echo $var
---> Running in a359d6d23c99
value
---> 80d30528cb2f
Removing intermediate container a359d6d23c99
Step 4/5 : FROM alpine
---> 7328f6f8b418
Step 5/5 : RUN echo $var
---> Running in a98c86de2859
---> e13e8e88531a
Removing intermediate container a98c86de2859
Successfully built e13e8e88531a
FROM alpine
ENV var=value
RUN echo $var
FROM alpine
RUN echo $var
$ docker build .
Sending build context to Docker daemon 61.28MB
Sending build context to Docker daemon 86.15MB
Step 1/5 : FROM alpine
latest: Pulling from library/alpine
88286f41530e: Pull complete
Digest: sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe
Status: Downloaded newer image for alpine:latest
---> 7328f6f8b418
Step 2/5 : ENV var value
---> Running in c07c1aef8530
---> e49c9ab7b565
Removing intermediate container c07c1aef8530
Step 3/5 : RUN echo $var
---> Running in bb79cf1b0ac9
value
---> fadbe87bf1c6
Removing intermediate container bb79cf1b0ac9
Step 4/5 : FROM alpine
---> 7328f6f8b418
Step 5/5 : RUN echo $var
---> Running in ccf4603f3dae
---> 61a8fe637349
Removing intermediate container ccf4603f3dae
Successfully built 61a8fe637349
The text was updated successfully, but these errors were encountered:
Variables defined by
ARG
andENV
should be scoped to a build stage. Currently, features related to Dockerfile variables such astextDocument/definition
,textDocument/documentHighlight
,textDocument/hover
, andtextDocument/rename
are all getting spanned across multiple build stages.Renaming a variable in one build stage will cause the similarly named ones in another other build stage to be renamed and highlighting a variable will highlight all the instances in the Dockerfile when the highlighting should only be scoped to the build stage that encompasses the instruction with that variable. Similarly, hovering over a variable will incorrectly display defined values from an earlier build stage when it should be empty if that variable has never been declared in the current build stage. Also, opening a variable's definition will jump to a declaration in an earlier build stage when the lookup should only be performed in the current build stage.
The
docker build
output below shows how variables should be scoped to its encompassing build stage. The secondRUN echo $var
statement prints nothing because the variable has not been defined in the second build stage.The text was updated successfully, but these errors were encountered: