For a long time I treated ARG and ENV as two spellings of the same thing. They are not, and mixing them up has two nasty side effects.
ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV
The docs describe build arguments as variables for the Dockerfile itself. You pass a value with docker build --build-arg NODE_ENV=development . and the default after the equals sign is used when you leave it out. Environment variables are passed to the build execution environment and, as the docs say, persist in containers started from the image.
The two lines above show how to combine them: the ARG takes the value at build time and the ENV copies it so the running container sees it as well. That example is straight from the Docker docs on build variables.
One more rule from the Dockerfile reference: an ENV instruction always overrides an ARG of the same name. So if you set both under one name, --build-arg will seem to be ignored after the ENV line.
The caveat is secrets. The docs warn that build arguments may persist in the image metadata and history, and that both arguments and environment variables are not suitable for secrets, because they are exposed in the final image. For a token during a build, use build secrets instead.
Further reading: Build variables, Dockerfile reference: ARG