Docker Community Forums

Share and learn in the Docker community.

Secrets with docker volumes in compose


(Meikle) #1

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


(King Chung Huang) #2

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


(Archimedes Trajano) #3

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