Can´t access ENV variables defined with Docker-compose

I have built three docker images:
(1) ShinyApp
(2) containerized shinyproxy
(3) NGINX image as reverse proxy

The dockerfile of (1) defines default ENV variables (e.g. db-credentials, configuration options, etc.). When running “docker-compose up” I want to overwrite these ENV variables.
To that end, I have placed a .env file with the ENV variables in the directory from which I run docker-compose (see: I access these variables with Sys.getenv(“variable_name”) from R.

My shinyApp consists of three files: ui.R, server.R and global.R.

Weirdly enough, I can access the correct overwritten ENV variables from the global.R whereas the server.R seems to access the ENV variables defined in the dockerfile.
However, I need to access the overwritten ones from server.R.

Any help or insight as to how this issue comes about it greatly appreciated.