the easiest way I made this work for now is as follows:
- on the host machine go to portainers data directory and then into the compose directory
- locate the latest compose file being used for the stack and cahnge to that directory
- create a .env file with the environment variable to be used e.g. PASSWORD=password
- in the stack in portainer add the env_file entry with ".env" and the variable name under the correct environment variable e.g.:
env_file:
- .env
environment:
- PASSWORD=$PASSWORD
- update the stack and should be good to go