Docker Swarm - Volume CIFS - Secrets

Hello, friends.

This is my first post so be nice.

The situation:
I deploy a docker-compose in swarm mode, I share a CIFS volume and I can access it.

The problem:
To access it I need to display my credentials in my docker compose file.

Possible solutions:
I’ve seen that it’s possible to use a secret, which could allow me not to leave my password in clear text, but I don’t know how to do it.

Can you help me?

The volume part of my docker compose file :

volumes:
postgresql_data:
driver_opts:
type: cifs
o: username=docker,password=P@ssw0rd,vers=2.0
device: //172.20.2.10/data/postgresql_data

I’ve already searched quite a bit on the internet and in the docker documentation but without success unfortunately.

Thanks to those who will take the time to help me.

docker volumes does not support the credentials option. When using cifs, there is no way around storing the credentials plain text when creating the volume. Even if the volume is created on the cli, a simple docker volume inspect will show the credentials. That’s why I use nfsv4 instead.

2 Likes

Thank you very much meyay for your quick reply, I searched a lot without finding an answer to my problem, but now I understand.

Do you have an example with NSFv4 ?

You already found an example by using the forum search, that’s why I didn’t paste an identical looking example here.

The discussion is continued in (including a valid example for nfsv4 mounts):

2 Likes