• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Resolved Plesk Docker extension Stacks not picking local .env

LytraX

New Pleskian
Server operating system version
Ubuntu 24.04
Plesk version and microupdate number
Plesk Obsidian Web Pro Edition 18.0.66
I am trying to setup some docker services using Plesk Docker Stacks and a local docker-compose.yml located inside webspace directory.

The issue is that the .env file is not picked by docker compose when the extension spins up the custom docker compose command, I have to use `env_file: .env` on each container for it to pick the environment variables the .env contains. This works but the problem with this is now every environment variable inside the .env is exposed in every container, which of course is a security issue, I don't want to expose secrets to containers of other unrelated services. I can make separate .env files for each service, but then my application picks only one .env file which expects all the variables of all the services to live inside.

Can someone confirm that Plesk Docker Stacks is not picking .env file that lives inside the same dir as the docker-compose.yml is located in?

If this is the case, is this an intented behaviour or it should pick the .env file when creating a new Stack?
 
Can someone confirm that Plesk Docker Stacks is not picking .env file that lives inside the same dir as the docker-compose.yml is located in?

If this is the case, is this an intented behaviour or it should pick the .env file when creating a new Stack?

Hi LytraX,

According to the Docker documentation, I would say it is expected behavior. Let me provide an example with Plesk; I will create two files, docker-compose.yaml and .env, and save them together in the subscription's Home directory,


  • docker-compose.yaml
Code:
services:
  my:
    image: busybox:latest
    command: env
    environment:
      - TEST=my_value
      - FROM_FILE=${VALUE_FROM_FILE}

  • .env
Code:
VALUE_FROM_FILE=foobar_from_.env_file



The result of starting the container is...
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=0c53aefa734f
TEST=my_value
FROM_FILE=foobar_from_.env_file
HOME=/root
 
Hey @AYamshanov, thanks for replying.

I just tried your example and it worked, it picks the FROM_FILE env var from the actual .env file!

My bad, I did forget to add a specific environment variable inside docker-compose.yml and thus it was failing.

There is no issue, it works as expected.

Thanks again for testing this.
 
Back
Top