Skip to content

CUPS printer in container

mviereck edited this page Jul 24, 2019 · 3 revisions

Container access to CUPS printer server on host

CUPS over UNIX socket

  • Check output of lpstat -H. It should point to a socket, normally /run/cups/cups.sock.
  • Share CUPS socket with container: --volume /run/cups/cups.sock:/run/cups/cups.sock
  • Set environment variable CUPS_SERVER with: --env CUPS_SERVER=/run/cups/cups.sock
  • The docker image needs package libcups or libcups2.

x11docker provides CUPS printer sharing with option --printer.

CUPS over TCP

To access CUPS printer server over TCP you must allow access in /etc/cups/cupsd.conf:

Port 631
<Location />
  # Allow remote access...
  Order allow,deny
  Allow 172.17.0.*
  Allow 127.0.0.1
#  Allow all
</Location>
  • The IP mask 172.17.0.* matches the IP range of Docker containers.
  • Set environment variable --env CUPS_SERVER=172.17.0.1:631.
    • IP 172.17.0.1 is the IP adress of the Docker daemon on host. Compare output of ip -4 a | grep docker
    • x11docker supports CUPS over TCP with option --printer=tcp.
Clone this wiki locally