12

With the influx of GUI applications being ported to docker, what is the best way to print to cups from inside a docker container?

NB: I am not looking to run cups from inside the container as this breaks the single service paradigm associated with docker.

Chris Daish
  • 283
  • 1
  • 2
  • 9

1 Answers1

12

Self Documenting after investigation work on how to achieve this goal.

Mounting in the cups socket worked great...ish (acroread failed to populate printers) with an Ubuntu based docker host, however this failed with a Redhat host.

...
-v /var/run/cups:/var/run/cups:ro
...

Populating the cups client.conf appeared to be a better solution.

cat /tmp/client.conf

#The ServerName directive specifies sets the remote server 
# that is to be used for all client operations. That is, it 
# redirects all client requests to the remote server. The 
# default port number is 631 but can be overridden by adding
# a colon followed by the desired port number to the value.
# The default is to use the local server ("localhost").
ServerName <DOCKER0 BRIDGE IP>

and the docker launch argument:

...
-v /tmp/client.conf:/etc/cups/client.conf:ro \
...

I also had to ensure the cups server would bind to the docker0 bridge and allow other devices to access the cups server:

...
Listen *:631
...
<Location />
  Order allow,deny
  Allow all
</Location>
...

Once cups had restarted and the cups client.conf passed into the container I was able to print as expected.

Chris Daish
  • 283
  • 1
  • 2
  • 9
  • from your docker launch argument, it appears that you make a `client.conf` file on your host at `/tmp/client.conf` and then mount it inside your container at `/etc/cups/client.conf` (as read-only). Are you printing **to** your docker container or **from** it to your host? – waspinator Sep 11 '16 at 00:28
  • just looking through some documentation, and it seems using client.conf is deprecated. You should have a CUPS server installed locally inside the container, and then print to a remote CPUS server from the local one. Doesn't look like there's a way around this to have a "single service paradigm". There's precedent already with php+apache containers anyway. https://wiki.archlinux.org/index.php/CUPS#Without_a_local_CUPS_server – waspinator Sep 11 '16 at 01:57