Sign inSign up

aguslr/samba

By aguslr

Updated 22 days ago

Set up a Samba server to share files over the network

Image
1

10K+

aguslr/samba repository overview

aguslr/docker-samba

docker-pulls image-size

This Docker image sets up Samba inside a docker container.

Samba is a free software re-implementation of the SMB networking protocol.

Installation

To use docker-samba, follow these steps:

  1. Clone and start the container:

    docker run -p 445:445 \
      -e SAMBA_USER=bob \
      -e SAMBA_PASS=123456 \
      -v "${PWD}"/home:/home \
      docker.io/aguslr/samba:latest
    
  2. Configure your Samba client software to connect to your Samba server's IP address with user SAMBA_USER.

Variables

The image is configured using environment variables passed at runtime. All these variables are prefixed by SAMBA_.

VariableFunctionDefaultRequired
USERUsername of Samba usersmbuserN
PASSPassword of Samba userautogeneratedN
UIDUID of Samba user11000N
PASSWDFILEValid smbpasswd fileemptyN
USERSFILEFile with user listemptyN
Adding users

A default user is created with username smbuser (or the value of SAMBA_USER) and an autogenerated password if none is provided with the variable SAMBA_PASS. To see the autogenerated password, check the log for the container:

docker logs <container_name> | grep '^Password'
Importing smbpasswd file

Alternatively, if a valid smbpasswd file is provided, its users will be added to the system and it will be imported using pdbedit. The same tool can be used to export the file from a working Samba setup:

pdbedit -e smbpasswd:/tmp/smbpasswd
Parsing user file

A third option that provides finer control is provided. Using the variable SAMBA_USERSFILE, the path to a file with users' information can be passed to the container.

This file should have one user per line in the format UID:NAME:GROUP:NTHASH. For example:

1000:smbuser:users:32ED87BDB5FDC5E9CBA88547376818D4

The command tool mkpasswd can be used to get NT-Hashes from plain text passwords:

mkpasswd --method=nt 123456

This command would ouput as used in the example above:

$3$$32ed87bdb5fdc5e9cba88547376818d4
Custom smb.conf

To configure additional shares or parameters, we can add these to a smb.conf file:

[Data]
  path = /data
  comment = Data directory
  available = yes
  browseable = yes
  read only = yes
  valid users = @users @nogroup
  write list = @users

Then, we can go ahead and mount it as follows:

docker run -p 445:445 \
  -e SAMBA_PASSWDFILE=/tmp/smbpasswd \
  -v "${PWD}"/smbpasswd:/tmp/smbpasswd \
  -v "${PWD}"/data:/data \
  -v "${PWD}"/home:/home \
  -v "${PWD}"/smb.conf:/etc/samba/includes.conf \
  docker.io/aguslr/samba:latest

Build locally

Instead of pulling the image from a remote repository, you can build it locally:

  1. Clone the repository:

    git clone https://github.com/aguslr/docker-samba.git
    
  2. Change into the newly created directory and use docker-compose to build and launch the container:

    cd docker-samba && docker-compose up --build -d
    

Tag summary

Content type

Image

Digest

sha256:138431cf3

Size

65.5 MB

Last updated

22 days ago

docker pull aguslr/samba