Search code examples
dockerfiledevops

Order in dockerfile: will this throw error


RUN echo $MY_VARIABLE
ENV MY_VARIABLE="some value"



instead should i write like

ENV MY_VARIABLE="some value"
RUN echo $MY_VARIABLE

i want to know does order matter in dockerfile if i write run command first then put the ENV will it throw an error


Solution

  • Yes , I believe the order does matter. You should first declare the variable and set it.