beginnerDockerfile Instructions & Multi-Stage Builds
What is the difference between ARG and ENV?
ARG defines a variable available only during the image build process (docker build --build-arg) and is not present in the final running container by default. ENV defines a variable baked into the image and available to every process in every container started from it, both at build time (for subsequent instructions) and at runtime. You can promote an ARG into an ENV explicitly if you need its value available at container runtime.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response