nextcloud-printer icon indicating copy to clipboard operation
nextcloud-printer copied to clipboard

nextcloud-printer within docker

Open Mailblocker opened this issue 4 years ago • 2 comments

Hi, thanks for the great addon e-alfred! After some investigation I got it working for my nextcloud instance running within a docker container. I leave it here, just in case someone needs this.

Preconditions

  1. A running CUPS server with a shared printer accessable via IPP over the internal network
  2. A nextcloud docker instance

The following changes will build the docker nextcloud image based on nextcloud:fpm (if needed change the image) with the packages cups-client, cups-daemon and cups-bsd installed. Additionally a startup script (myNextcloud.sh) is added. It will start the cups service, add a remote printer (change the IP and the printer name accoringly to the CUPS server) via IPP and set this printer as the default CUPS printer. Afterwards the entrypoint.sh script of the docker nextcloud image is started.

docker compose file

...
  nextcloud:
#    image: nextcloud:fpm
    build:
      context: .
      dockerfile: myNextcloud
...

Dockerfile: myNextcloud

FROM		nextcloud:fpm
ADD		myNextcloud.sh /
RUN		apt-get update && apt-get install -y cups-client cups-daemon cups-bsd && chmod +x /myNextcloud.sh
ENTRYPOINT	["/myNextcloud.sh"]
CMD		["php-fpm"]

Startscript: myNextcloud.sh

#!/usr/bin/env sh
service cups start
lpadmin -p HP_M281_docker -E -v ipp://192.168.2.42:631/printers/HP_M281 -m everywhere
lpoptions -d HP_M281_docker
sh /entrypoint.sh "$@"

@e-alfred If needed feel free to add it to the documentation, I can also provide a PR.

Question: Is it possible to use lp instead of lpr as the printer command in the plugin? Doing this would not make it neccessary to install cups-bsd.

Mailblocker avatar Jun 02 '20 18:06 Mailblocker

If you can make a PR, that would be awesome! Using lp instead of lpr might be possible but I had some permissions problems with it so I opted for lpr for now.

e-alfred avatar Jun 08 '20 21:06 e-alfred

Ah okay, could be since I'm using the plugin within a docker container the call lpr should be executed as root. Therefore I might not have any troubles with lp but others might.

Mailblocker avatar Jun 11 '20 16:06 Mailblocker