Starting samba in a torizon/weston-vivante container

I’m using a Verdin iMX8M Plus and a Verdin development board. I’m using a TorizonCore reference image with sample containers. I have a docker image based on torizon/weston-vivante:2 with minimal changes.

I’m trying to get samba to run inside the container. I’ve installed the samba package in the docker build and am first trying to get it to run by manually starting it.

First attempt was systemctl, that returns “command not found”. I installed a package with it in the docker build, then trying it returns “System has not been booted with systemd as init system (PID1).” I don’t want to install systemd assuming that will break whatever all /usr/bin/entry.sh does.

Then I tried “service”. Doing a “service --status-all” shows a samba-ad-dc service, status is [-] not running. I did a “service samba-ad-dc start”, it came back to the command prompt with no errors. But checking status again shows samba still not running.

How do you start services inside a TorizonCore Debian container? Do I need to install systemd? TorizonCore itself has systemctl, as did the Colibri Yocto T30 environment we are upgrading from.

Greetings @techczech,

It is possible to run systemd inside a container. But it can be more trouble and effort than needed.

As for your issue, if all you want to do is run samba-ad-dc.service, can’t this be done without systemd/systemctl?

Looking at the service file itself:

root@fec3ffa2a8da:/# cat /etc/systemd/system/multi-user.target.wants/samba-ad-dc.service
[Unit]
Description=Samba AD Daemon
Documentation=man:samba(8) man:samba(7) man:smb.conf(5)
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=notify
PIDFile=/run/samba/samba.pid
LimitNOFILE=16384
EnvironmentFile=-/etc/default/samba
ExecStart=/usr/sbin/samba --foreground --no-process-group $SAMBAOPTIONS
ExecReload=/bin/kill -HUP $MAINPID


[Install]
WantedBy=multi-user.target

All this service seems to do is execute /usr/sbin/samba --foreground --no-process-group $SAMBAOPTIONS. You should be able to do this yourself from the command line or from a script. Assuming Samba requires nothing else, I’m not very familiar with actually working with Samba. This way you’re not relying on systemd/systemctl in a container to start this service file.

Alternatively, there is also many Samba container images on Dockerhub you can use a reference. For example this one seems pretty popular: Docker Hub

Mind you these container images are not created or maintained by Toradex, but they’re still resources you can use.

Best Regards,
Jeremias

Solved, I have something working. Thanks again for your help.

I’ve never run it directly, always as a service on other systems, including the Colibri T30.

I’m calling /usr/sbin/smbd --daemon --no-process-group from a script that runs at startup.

Some things still seem odd to me. For example “service” will now list smbd as a running service. But attempt to use it to do anything else with smbd and it will claim it doesn’t know what it is. But what we needed works, so ignoring things like that.

Glad I was able to help!

Some things still seem odd to me. For example “service” will now list smbd as a running service. But attempt to use it to do anything else with smbd and it will claim it doesn’t know what it is. But what we needed works, so ignoring things like that.

Yeah systemd/service type stuff inside a container gets a bit weird. Of course from the perspective of service it doesn’t realize it’s in a container and not a full system. Like I said while it is possible to get systemd going inside a container, the complexity it brings is usually not worth it.

For example our containers that run Weston. Typically on a non-container system Weston is started with a service. However in our containers we invoke the Weston binary directly via a startup script, similar to what you did here for Samba.

Best Regards,
Jeremias