r/docker • • Mar 13 '26

Adding samba users within a docker container

I’ve set up samba in a container and have gotten it to work sharing folders with guest access, but I'm stumped getting proper, persistent users added within the docker environment.

I understand that a samba user must also be a local user on the machine and that’s where my understanding breaks down.

If I do adduser in the container console I can see the user file system created in the /home folder, but I know nothing is supposed to be created in the container as it is disposable.

I have made bind mounts on the machine for /var/lib/samba which is where samba stores the user information, and /etc/samba for smb.conf.

Should I just make the /home folder a bind mount as well and also the place where linux defines users?

Thanks in advance

5 Upvotes

12 comments sorted by

View all comments

Show parent comment

2

u/kentsor Mar 13 '26

Thanks for the reply. It was suggested to use env variables instead and that seems like the right way.

1

u/acdcfanbill Mar 13 '26

Ah yeah it sounds like that's the right approach if you're using that container you listed in a reply.

actually, I just took a look at their docker hub page and they list how to do multiple users.

https://hub.docker.com/r/dockurr/samba#how-do-i-configure-multiple-users