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.