diegogslomp / samba-ad-dc

🐳 Docker image of Samba domain controller compiled from source
https://hub.docker.com/r/diegogslomp/samba-ad-dc
GNU General Public License v3.0
46 stars 18 forks source link

Request [ARM64] #10

Closed finnie2006 closed 1 year ago

finnie2006 commented 1 year ago

It would be cool if there would also be an arm64 version so i can run it on my pi

diegogslomp commented 1 year ago

Hello!

I built an arm64 image with:

# Register QEMU binaries
docker run --privileged --rm tonistiigi/binfmt --install all

# Check available platforms
docker buildx ls

# Build image with platform
cd samba-ad-dc
docker buildx build --platform="linux/arm64" -f dockerfiles/almalinux --tag samba:arm64 .

In the future I can add that to the main repo, but I need to learn more about the docker buildx driver for multplatform builds. Please try this and any trouble let me know.

diegogslomp commented 1 year ago

So, it was easier than I expected (source), but the emulated build process is very slow. Arm64 platform image added. Please test using the diegogslomp/samba-ad-dc:arm64 version and any trouble let me know.

finnie2006 commented 1 year ago

Cool i will test it in an hour

finnie2006 commented 1 year ago
Traceback (most recent call last):

  File "/usr/local/samba/bin/samba-tool", line 34, in <module>

    from samba.netcmd.main import samba_tool

  File "/usr/local/samba/lib64/python3.9/site-packages/samba/__init__.py", line 28, in <module>

    import ldb

ModuleNotFoundError: No module named 'ldb'
diegogslomp commented 1 year ago

It seems that the python3-ldb should be installed, on monday I'll add it to the dependencies and we test it again.

finnie2006 commented 1 year ago

I will try it i know how to modify the dockerfile and build using buildx i will let you know

diegogslomp commented 1 year ago

I'm trying to build it but it is too slow.. and I need to go.. so

image

You can build with

 docker buildx build --platform="linux/arm64" -f dockerfiles/almalinux --tag samba:arm64 .

Just add python3-ldb to the install dependencies in the dockerfiles/almalinux file

finnie2006 commented 1 year ago

👍🏻, i an running ubuntu btw should i pick the ubuntu dockerfile?

diegogslomp commented 1 year ago

You can build the ubuntu image too.. but the dockerhub image is based in almalinux. Your host can be any other distro too.

finnie2006 commented 1 year ago

Oh like that

finnie2006 commented 1 year ago

Building it, but is compiling really required? or should there be a way to modify it by just installing the samba package Also the image is pretty big

diegogslomp commented 1 year ago

If the error happens after the build you can try install the package after all process. I'll start to build the image now and I'll upload it in the sequence.

diegogslomp commented 1 year ago

Image uploaded, please check if the ldb error is happening now

finnie2006 commented 1 year ago

I will try, when i tried the non working image from yesterday i saw that the container was over 1gb that is pretty big for a container but hm

diegogslomp commented 1 year ago

It is big, since this image compiles samba from source there are many dependencies.

REPOSITORY                TAG          IMAGE ID       CREATED          SIZE
samba                     rockylinux   b59a12e8a6ff   12 seconds ago   1.06GB
samba                     debian       12144e37c344   12 seconds ago   1.17GB
samba                     almalinux    e958cef7dac5   12 seconds ago   1.06GB
samba                     ubuntu       66bc9b8700a1   14 seconds ago   1.13GB

The ubuntu image has a samba that can be installed from the repository, you can try using that if you need a smaller image.

finnie2006 commented 1 year ago

Oh oke, pulling it afbeelding

finnie2006 commented 1 year ago

unfortunately it gave an error again


ModuleNotFoundError: No module named 'samba.param'

Traceback (most recent call last):

  File "/usr/local/samba/bin/samba-tool", line 34, in <module>

    from samba.netcmd.main import samba_tool

  File "/usr/local/samba/lib64/python3.9/site-packages/samba/__init__.py", line 29, in <module>

    import samba.param
diegogslomp commented 1 year ago

Which python version the arm64 version runs?

docker run -it --rm diegogslomp/samba:arm64 python --version
docker run -it --rm diegogslomp/samba:arm64 python2 --version
docker run -it --rm diegogslomp/samba:arm64 python3 --version

Maybe I need to change the script to python3 samba-tool instead samba-tool

diegogslomp commented 1 year ago

So... I haven't had any success running arm64 images on amd64, docker run --platform linux/arm64 samba:arm64 cmd just gives me exec errors for every command, even an official arm64 image gives me errors, or I'm doing something wrong, or it just doesn't work. I'll update if I can get this to work.

diegogslomp commented 1 year ago

Arm64 version built with docker buildx build --platform linux/arm64 and tested with docker run --platform linux/arm64. Now should work on pi.

finnie2006 commented 1 year ago

I am so sorry, i had no time and kinda forget about it, tried the latest image but still

image

Edit: i see ldb is not in the Dockerfiles

finnie2006 commented 1 year ago

I tried to compile it, took pretty long but now i have this

Traceback (most recent call last):

  File "/usr/local/samba/bin/samba-tool", line 34, in <module>

    from samba.netcmd.main import samba_tool

  File "/usr/local/samba/lib64/python3.9/site-packages/samba/__init__.py", line 29, in <module>

    import samba.param

ModuleNotFoundError: No module named 'samba.param'
diegogslomp commented 1 year ago

Hello

Today I built the 4.18.3 version without problems. I use the build script to do that.

In my case I build it on a amd64 debian pc, so first I check if can build arm64:

docker buildx ls | grep arm64

If not, I enable arm64:

docker run --privileged --rm tonistiigi/binfmt --install all

Check again:

docker buildx ls | grep arm64

Then build:

docker buildx build \
  --platform linux/arm64 \
  -f dockerfiles/almalinux \
  --load --no-cache --tag samba:arm64 .

You can use the dockerhub image built today too.

When I had similar problems it was related to the wrong amd/arm image used by the buildx command.

finnie2006 commented 1 year ago

Building is not the problem, the problem occurs when trying to run the container, also with 4.18.3

I tried changing the dockerfile and added python3-ldb and after that i got the second error i sended you when running the container

Same issue as here: https://github.com/diegogslomp/samba-ad-dc/issues/10#issuecomment-1464936832 Your suggestion: https://github.com/diegogslomp/samba-ad-dc/issues/10#issuecomment-1465976296

In the sbin folder i changed samba-tool to python3 samba-tool building and testing now

diegogslomp commented 1 year ago

To run an arm64 image on a amd64 pc I need t o add the --platform option to the docker run command like this:

docker run -d --privileged \
  --restart=unless-stopped \
  --network=host \
  --platform linux/arm64 \
  -e REALM='DGS.NET' \
  -e DOMAIN='DGS' \
  -e ADMIN_PASS='Passw0rd' \
  -e DNS_FORWARDER='8.8.8.8' \
  -v dc1-samba:/usr/local/samba \
  --name dc1 --hostname DC1 samba:arm64

What i the output of the command below:

docker run -it --rm --platform linux/arm64 samba:arm64 uname -r
finnie2006 commented 1 year ago

Did you read my reply? also i am on arm64 and build and using it on arm64 in this case

diegogslomp commented 1 year ago

The time I had similar problems I was trying to compile/run the image in a wrong architecture, it seems the problem is with python packages but it was only build/buildx problems, even if you add the packages that are "missing" you will get other errors, the current dockerfile has been tested and runs without problems.

So before build the architecture linux/arm64 should be printed with docker buildx ls, build it with docker buildx --platform linux/arm64 and run it with docker run --platform linux/arm64

diegogslomp commented 1 year ago

Run and print here the results of the commands:

uname -r
docker buildx ls

Try using the diegogslomp/samba-ad-dc:arm64 not the compiled samba:arm64 to run the container and print results too.

finnie2006 commented 1 year ago

image

diegogslomp commented 1 year ago

Here are my output for reference:

~/repos/samba-ad-dc (master) docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS  BUILDKIT                              PLATFORMS
default * docker
default default         running v0.11.7-0.20230525183624-798ad6b0ce9f linux/amd64, linux/amd64/v2, linux/386, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
~/repos/samba-ad-dc (master) docker run -it --platform linux/arm64 --rm samba:arm64 uname -m
aarch64
~/repos/samba-ad-dc (master) docker run -it --rm samba:almalinux uname -m
x86_64
~/repos/samba-ad-dc (master) uname -m
x86_64

Your output of the uname -r is empty, how about the uname -m or uname output?

finnie2006 commented 1 year ago

image

diegogslomp commented 1 year ago

So the aarch64 matches the image version and when you pull it from dockerhub it should bring the right one. You said that you can build the image without problems too, but using the compiled one shows the same errors.

Can you at least print the samba version from your compiled one?

docker run -it --rm samba:arm64 samba --version

At home I'll try to compile and run it from a windows, using same scripts that I run it on linux, since I don't have an arm64 to test it.

finnie2006 commented 1 year ago

Version 4.18.3

diegogslomp commented 1 year ago

Hello

I uploaded the arm64 image compiled using a Windows environment, please test it in your pi, lets see if the output changes.

finnie2006 commented 1 year ago

image

sadly enough it did not

diegogslomp commented 1 year ago

Hello

I compiled a 4.17.8 version for diegogslomp/samba-ad-dc:arm64, please check if this one shows same errors

finnie2006 commented 1 year ago

afbeelding

Pulled the new image but still the same, i really think the image would need a modification to work on arm

finnie2006 commented 1 year ago

Any thoughts? it is running python3

image

image

finnie2006 commented 1 year ago

Seems like something with the env variable for samba, but i am stuck now, giving up for now

diegogslomp commented 1 year ago

Here's my output using windows environment:

PS C:\Users\diego> docker run -d --privileged   --restart=unless-stopped   --network=host   --platform linux/arm64   -e REALM='DGS.NET'   -e DOMAIN='DGS'   -e ADMIN_PASS='Passw0rd'   -e DNS_FORWARDER='8.8.8.8'   -v dc1-samba:/usr/local/samba   --name dc1 --hostname DC1 diegogslomp/samba-ad-dc:arm64
PS C:\Users\diego> docker exec -it dc1 uname -m
aarch64
PS C:\Users\diego> docker exec -it dc1 python3 --version
Python 3.9.16
PS C:\Users\diego> docker exec -it dc1 samba-tool
Usage: samba-tool <subcommand>

Main samba administration tool.

Options:
  -h, --help       show this help message and exit

  Version Options:
    -V, --version  Display version number

Available subcommands:
  computer    - Computer management.
  contact     - Contact management.
  dbcheck     - Check local AD database for errors.
  delegation  - Delegation management.
  dns         - Domain Name Service (DNS) management.
  domain      - Domain management.
  drs         - Directory Replication Services (DRS) management.
  dsacl       - DS ACLs manipulation.
  forest      - Forest management.
  fsmo        - Flexible Single Master Operations (FSMO) roles management.
  gpo         - Group Policy Object (GPO) management.
  group       - Group management.
  ldapcmp     - Compare two ldap databases.
  ntacl       - NT ACLs manipulation.
  ou          - Organizational Units (OU) management.
  processes   - List processes (to aid debugging on systems without setproctitle).
  rodc        - Read-Only Domain Controller (RODC) management.
  schema      - Schema querying and management.
  sites       - Sites management.
  spn         - Service Principal Name (SPN) management.
  testparm    - Syntax check the configuration file.
  time        - Retrieve the time on a server.
  user        - User management.
  visualize   - Produces graphical representations of Samba network state.
For more help on a specific subcommand, please type: samba-tool <subcommand> (-h|--help)

I tested this with Almalinux, Rockylinux, Debian and Ubuntu, the main image from dockerhub is in Almalinux, I can upload another os to see if changes.

finnie2006 commented 1 year ago

Could try, but it is wierd that running it as arm64 goes completly fine for you but not for me

diegogslomp commented 1 year ago

So I compiled with linux/arm64/v8 as image tag and linux/arm64 as buildx platform, since the images from dockerhub use version in tag but buildx does not, please check the new diegogslomp/samba-ad-dc:arm64 and see if the result changes.

finnie2006 commented 1 year ago

image

Same result, but why do you not add ldb like it mentions?

diegogslomp commented 1 year ago

Ldb packages installed on the new arm64 image:

[root@DC1 sbin]# yum list installed | grep ldb
libldb.aarch64                          2.6.1-1.el9                   @baseos
python3-ldb.aarch64                     2.6.1-1.el9                   @baseos
finnie2006 commented 1 year ago

Now this error, afbeelding

Wierd because docker run -it --rm diegogslomp/samba-ad-dc:arm64 samba-tool does work

Maybe there is something wrong with the path

diegogslomp commented 1 year ago

Please try remove the old volume before run it:

docker volume rm dc1-samba

I just don't understand why I can't reproduce this bug here, if the problem was PATH I should have problems too.

finnie2006 commented 1 year ago

afbeelding

That fixed the issue great! no success with joining yet, does this docker version need port 53?

diegogslomp commented 1 year ago

Nice! Now you need to change the nameserver editing /etc/resolv.conf and add the dc1 to the /etc/hosts from your host machine. More info here.

Example /etc/resolv.conf:

search samdom.example.com
nameserver 10.99.0.1

Example /etc/hosts:

127.0.0.1     localhost
10.99.0.1     DC1.samdom.example.com     DC1
finnie2006 commented 1 year ago

Do i need to change dns forwarder to something else?

diegogslomp commented 1 year ago

No need, but you can use any dns you want, add more than one too, but the dns from your host should be the host ip address