To access to the printer from the docker container on Mac OS needs some tricks.
On you Mac OS please open /etc/cups/cupsd.conf and change:
Listen localhost:631
to
Listen 0.0.0.0:631
after this line also add:
BrowseAddress @LOCAL
and in the end of section <Location />
add:
Allow @LOCAL
Please save this file and restart CUPS daemon:
sudo launchctl stop org.cups.cupsd && sudo launchctl start org.cups.cupsd
Please go to Settings -> Printers & Scanners and for each printer, which you will use from the Docker, and make sure the option "Share this printer on the network" is enabled.
ip=$(ifconfig | grep -o "inet [^\n]*" | grep -v 127.0.0.1 | head -1 | cut -d\ -f2)
docker run -it --rm \
-e CUPS_SERVER=$ip:631 \
--privileged \
--network=host \
--entrypoint bash \
IMAGE_ID
REMARK: there is entrypoint to the bash just for testing only. You could change it according to your needs.
Also, probably, --privileged
option is not required here.
This command (in the container) should show your printers:
lpstat -p