How to set Docker Secrets (FILE__PASSWORD) in docker-compose.yml

I’m running Docker Swarm, and it would be handy to use environment variables from files (Docker secrets).

I have trouble how to translate the directive:
-e FILE__PASSWORD=/run/secrets/mysecretpassword

Does someone have an example how this should look on my compose file?!

-e is environment, so it goes in your environment section of the compose

Yes, but that’s not all there is more needed…

As a visual, thinker, I just like to see a complete compose file, from a working config!?

This doesn’t work unfortunately:

services:
  freshrss-app:
    image: lscr.io/linuxserver/freshrss:latest
    container_name: freshrss-app
    hostname: freshrss
    restart: unless-stopped
    ports:
      - 8111:80/tcp
    environment:
      - FILE__PASSWORD=/run/secrets/mysecretpassword
    env_file:
      - ../global.env
      - freshrss.env
    volumes:
      - freshrss:/config
    networks:
      - default

The Env value becomes: FILE__PASSWORD=/run/secrets/mysecretpassword and not what I set as my mysecretpassword in Swarm.

I park it for now, but if someone knows how to do this, please reply.

What are you exactly expecting to happen? There is no authentication ENV’s for freshrss so if you provide a password env, nothing is going to happen.

I know FreshRSS is just a random container to test,

What I expect, is that the Docker Swarm Secret or config items end up in an environment variable.

Otherwise i don’t understand what - FILE__PASSWORD=/run/secrets/mysecretpassword is for?

can you show an example where the environment variable you’re using is a real variable?

What are you currently doing is setting the environment variable called “FILE__PASSWORD” to a specific path.
If you want the content of that file to become a environemnt variable you need to specifiy the docker compose like:

services:
  freshrss-app:
    ....
    env_file:
      - /run/secrets/mysecretpassword
    ....

The content of “mysecretpassword” should then be a line-by-line list of “key=value” entries.

For better explanation please see: