I've tried unsuccessfully to set environment variables in a Docker container during the build. Using the run command to set them works, but I need to do it during the build.
Here's dockerfile
FROM ubuntu:latest
ARG TEST_ENV=something
My build command
docker build -t --build-arg TEST_ENV="test" myimage .
My run command
docker run -dit myimage
Using below command to check available environment variables
docker exec containerid printenv
My result
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=e49c1abfd58b
TERM=xterm
no_proxy=*.local, 169.254/16
HOME=/root
TEST_ENV is not present here