Docker With Samba Server#
What Is The Samba Server?#
- A Samba file server enables file sharing across different operating systems over a network. It lets you access your desktop files from a laptop and share files with Windows and macOS users.
Create Samba Server With Docker#
- Let's create a file name
docker-compose.yml
, then add scripts as below:
docker-compose.yml | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
-
In the
environment
, at lineSHARE=Data;/mnt;yes;no;no;duc;none;none;Data
please change the usernameduc
to the username of the user that you define at lineUSER=duc;itworked
. We haveData
: is the share name./mnt
: The path inside the container that is being shared.no
: Whether guest access is allowed (no guest access).no
: whether the share is browsable.none
: Placeholder, possibly for a password or other options.none
: Placeholder, possibly for another option.Data
: The share comment or description.
-
USER=duc;itworked
Creates a Samba user duc with the password itworked. - In the
volumes
we have/home/duc/share:/mnt:z
: Mounts the host directory/home/duc/share
to the container directory/mnt
. The:z
suffix is used for SELinux-enabled systems to apply the correct labels for shared volumes.
Testing#
- Now you can use command
docker-compose up
to start yourSamba
server. - Then on your client machine let open
Files
then chooseOther Locations
. At the bottom let's put the prefixsmb://
and the ip address of your server machine and clickConnect
- Then we will see the share name and when we double click on that, we will be required to put the username and password. So let's use the username and password that we created in the
docker-compose.yml
.
- Then after we connected, we can share files between two machines.
- If you can not copy and paste file from your client machine, please check the
read
,write
permission andowner
on the share folder in your server machine. We can use command below to grant all permission on the share folder.
1 |
|
- Then for changing the owner of the folder.
1 |
|