olbat / dockerfiles

A collection of Dockerfiles
https://hub.docker.com/u/olbat/
GNU General Public License v3.0
134 stars 73 forks source link

Include Samba in CUPS for automatic printer discovery on Windows #101

Open Loizzus opened 7 months ago

Loizzus commented 7 months ago

In the repo olbat/cupsd it would be nice to have Samba pre-installed and pre-setup so that it broadcasts all printers to Windows computers by default.

Sorry if this is already happening, I couldn't figure out how.

Jacksaur commented 6 months ago

Seconding this, it'd be really helpful, and avoid installing to the host instead. I tried adding it myself, but it doesn't seem available in the repositories when apt is ran inside the image...

olbat commented 6 months ago

Actually smbclient is already installed, see https://github.com/olbat/dockerfiles/blob/master/cupsd/Dockerfile#L21 .

However, I don't know how to configure it, is it enough to have it in the image alongside cupsd? If it requires another service then it should run using another container.

Jacksaur commented 6 months ago

Smbclient just allows CUPS access to SMB shared printers. "Samba" is the package that actually provides server functionality.

Samba itself is configured through /etc/samba/smb.conf, which interestingly already exists despite Samba not being installed. I guess Debian Lite drops Samba but not the config files.

olbat commented 6 months ago

Samba is another daemon that should be launched separately from cupsd. Perhaps you could use another Docker image & container for that purpose & make it communicate with cupsd?

Loizzus commented 5 months ago

Why do you say it should be launched separately? At the end of the day the goal of a print server is to make managing printers effortless across all platforms. At the moment with it not being able to broadcast itself to windows devices it makes it mostly useless as in the business world the vast majority of end user devices are Windows machines. And almost nobody outside of businesses need a print server.

olbat commented 5 months ago

Why do you say it should be launched separately?

Because that's how Docker has been designed to work: one system/service/function per container. You can learn more about that here for example.

If you need Samba for your use-case, just create a Samba image, spin up a the service in a container and connect it to the cupsd one. Docker compose can help you to make that procedure less cumbersome.

Loizzus commented 5 months ago

Hey, while yes I completely agree with limiting the scope of a container to it's specific function (the Apache + MySQL example is a great example of what not to do) I don't think this applies to this situation. Making printers discoverable to Windows devices is a core function of CUPS and without it it isn't going to be useful to most people. Also having multiple instances of this container running with Samba in all of them will not have any negative consequences, it is still just as scalable.

While yes it would probably be possible to write a compose file with shared volumes between the CUPS container and a dedicated samba container that is a very overcomplicated solution for something that should just be packaged together.

But at the end of the day it is your project, I won't push you to add it any more. I also won't make a fork of the project as is yours is the most popular CUPS container and we really don't need yet another forked project. I was just hoping to make it slightly more useful.

olbat commented 5 months ago

I get your point. Yet, properly instantiating and keeping track of multiple services in a single container requires extra work and can degrade the stability of the main service. If for some reasons the samba service stops, the cups service will have to be stopped as well, which will have a negative impact for users that don't care at all about Samba. Understanding the logs also becomes harder as everything gets mixed up.

If you want to implement your own Samba image & cups config please go for it. I can reference your config & work in the doc of this project to help others to get the same setup up & running. What I won't do is running another service in the same container.