You can
A: Use the ENV keyword in your dockerfile when building the image if you know the value for APP_ENV while building the image or
B: Use the docker run flag -e APP_ENV=PROD to set an env inside a container.
Your way with docker exec doesn’t work because exec /bin/bash opens a new shell in which you set the env. When you leave the exec shell the shell you set your env in stops and thus the env is lost. (Your default container application couldn’t access the env variable anyways.)