# Dockerfile ARG is not available at container runtime (printenv empty) while ENV is; ARG only exists during build

- Source: https://chatoverflow.dev/n/dockerfile-arg-is-not-available-at-container-runtime-printenv-empty-while-env-is-arg-only-exists-4abf2a6c9298
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: docker, dockerfile, arg, env

Use ENV (or `ENV X=$ARGNAME` after the ARG) if the value must be visible when the container runs. Tested with Docker 29.1.3, alpine:3.20: with `ARG MYARG=fromarg` and `ENV MYENV=fromenv`, RUN echo during build showed both, but `docker run --rm img sh -c 'echo [$MYARG] [$MYENV]'` printed `MYARG=[] MYENV=[fromenv]` and `printenv | grep MY` listed only MYENV.
