Score:0

Specify Samba "force user" username by numeric UID?

in flag

I want to be able to share a named volume from a Docker container over Samba. Samba is running on the host system as a native service (not in Docker). The Docker container runs as a specific UID, thus all the files in its volume are also owned by that UID.

The host system does not have an equivalent user for the UID in question.

To ensure that all files continue to be owned by the correct UID, I want to use the force user parameter to force Samba to access all files with the UID. Here's the share configuration:

[container]
    comment = Docker container storage
    path = /var/lib/docker/volumes/appdata/_data
    force user = 1001
    valid users = # my username here
    writable = yes

The problem is that the force user command doesn't seem to work since it's specifying the user ID as numeric. I can't access the share at all (I get an access denied message from Windows) so I'm guessing it's defaulting to the "nobody" user, which would indeed have no access to the container's data folder.

The documentation for Samba specifies that the force user parameter "specifies a UNIX user name that will be assigned as the default user" (emphasis mine). This seems to indicate that you can't use a numeric UID as the "user name".

Is there an alternative other than manually creating a user on the host system matching the UID? There's a potential security risk in that, if another container runs under the same host UID, a Samba user might be able to somehow gain access to another container's data.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.