Secrets with docker volumes in compose

I am running docker in Ubuntu, although I don’t think this is platform specific.

I have a service which shares a volume which used the local volume manager and cifs.

In my docker file I have:

volumes:
  nas-pics: 
    driver: local
    driver_opts:
      type: cifs
      device: //<ip-address>/<path> 
      o: "username=<username>,password=<password>"

This works fine. But I want to store my compose file without the cifs login details.
So I wanted to use docker secrets.

However this does not appear to be supported and I get errors when I try and define secrets access from the volumes definition.

Is there a better way to do this so that I don’t have to have the login details in the docker-compose file ?

Thanks
∕Ian

You could use variables for the username and password, and define them in your environment or via a .env file.

I use docker-volume-netshare which allows me to place the credentials elsewhere for my CIFS volumes.

@meikle, @kinghuang - were you able to substitute values using environment variables? I tried, but getting blank values?