Can the WORKDIR instruction resolve environment variables in Docker?
Experience Level: Senior
Tags: Docker
Answer
Yes. The WORKDIR instruction can resolve environment variables previously set using ENV. You can only use environment variables explicitly set in the Dockerfile. For example:
ENV DIRPATH=/path
WORKDIR $DIRPATH
Related Docker job interview questions
What is the EXPOSE instruction good for in Docker?
Docker SeniorWhat is the VOLUME instruction good for in Docker?
Docker SeniorWhat is the WORKDIR instruction good for in Docker?
Docker SeniorWhat is the USER instruction good for in Docker?
Docker SeniorHow do you copy files to your Docker image during built while configuring permissions as well?
Docker Senior