235 views
What is the difference between ENV and ARG in Dockerfile?
Asked at
AI answer
In a Dockerfile, ARG and ENV are used for different purposes:
-
ARGis a build argument. Its value can be passed during the image build process usingdocker build --build-arg. Arguments are only available at build time and are not stored in the final image. -
ENVis an environment variable that is stored in the image and available during container runtime.
Example:
ARG VERSION=1.0
ENV APP_VERSION=$VERSION
RUN echo "Building version $APP_VERSION"
Here, VERSION is set during build, and APP_VERSION will be available inside the container after it starts.
Also asked at Т-Банк
- Tell us about yourself and your experience (intro)
- Describe your experience in DevOps/SRE — what exactly did you do and what were you responsible for?
- What is the difference between Deployment, StatefulSet, and DaemonSet?
- Что такое healthcheck в Docker? Как правильно настроить? Пробы liveness и readiness в Kubernetes — как писали?
- How do you deploy Kubernetes and applications? Kubespray, Helm?