Have you failed a job interview?
Send us your job interview questions and get correct answers.

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

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker instructions
Docker instructions

Are you learning Docker ? Try our test we designed to help you progress faster.

Test yourself