How did I install Brother Printer HLL3240CDW Inside a container

The wireless printer of Brother HLL3240CDW does not have an open source driver. Since I don’t like to run a closed source program on my Linux, I preferred to install the driver inside a container. Most tutorials on the internet were about installing the driver on the host and accessing it from inside the container, or to allow a USB printer to be accessed from the container, etc. So I started to figure this out by myself and some help from chatGPT!
Step 1: Dockerfile

FROM devuan/devuan:latest

RUN apt update \
    && apt install -y \
        curl \
        cups \
        lpr

RUN curl \
        -s 'https://download.brother.com/welcome/dlf006893/linux-brprinter-installer-2.2.4-1.gz' \
        -o linux-brprinter-installer-2.2.4-1.gz \
    && gunzip ./linux-brprinter-installer-2.2.4-1.gz \
    && printf "y\nY\n8\n192.168.0.142\nN\n" | bash ./linux-brprinter-installer-2.2.4-1 HLL3240CDW

COPY ./entrypoint.sh /

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

Step 2: entrypoint.sh

#!/bin/bash
/usr/sbin/cupsd -C /etc/cups/cupsd.conf -s /etc/cups/cups-files.conf &
sleep 2
lpadmin -p HLL3240CDW -v lpd://192.168.0.142/BINARY_P1 -E
lpstat -p
# If no command is passed to the container, run bash by default
if [ -z "$1" ]; then
    exec /bin/bash
else
    # Run the command specified in the docker run arguments
    exec "$@"
fi

Step 3:
Some scripts to make printing easier for future:

print-a4.sh

#!/bin/bash

link=`readlink $0`
dir=`dirname "$link"`
cd "$dir"

if [ "x$2" != x ]; then
    pageRanges="-o page-ranges=$2"
fi

docker run \
    -ti \
    -v "$1"':/a' \
    printer \
    /bin/bash -c ' \
        lp \
            -d HLL3240CDW \
            '"$pageRanges"' \
            /a \
        && echo "Press enter once you are done." \
        && read \
    '

print-a4-color.sh

#!/bin/bash

link=`readlink $0`
dir=`dirname "$link"`
cd "$dir"

if [ "x$2" != x ]; then
    pageRanges="-o page-ranges=$2"
fi

docker run \
    -ti \
    -v "$1"':/a' \
    printer \
    /bin/bash -c ' \
        lp \
            -d HLL3240CDW \
            -o ColorModel=Color \
            -o BRMonoColor=FullColor \
            -o BRColorMatching=Normal \
            '"$pageRanges"' \
            /a \
        && echo "Press enter once you are done." \
        && read \
    '

print-photo.sh

#!/bin/bash

docker run \
    -ti \
    -v "$1"':/a' \
    printer \
    /bin/bash -c ' \
        lp \
            -d HLL3240CDW \
            -o ColorModel=Color \
            -o BRMonoColor=FullColor \
            -o BRInputSlot=Tray1 \
            -o BRMediaType=Glossy \
            -o PageSize=Postcard \
            -o BRResolution=600x2400dpi \
            -o BREnhanceBlkPrt=ON \
            -o BRColorMatching=Normal \
            -o BRPrintBorderless=ON \
            /a \
        && echo "Press enter once you are done." \
        && read \
    '

Of course you need to have docker installed on the host and know how to run docker and those bash scripts. But you get the idea. Hope it helps :slight_smile:

2 Likes

@aario thank you for sharing.

Now we just need some positive feedback from Brother printers owners, then we can move this how-to to Resources

2 Likes

Excuse me for asking a dumb question but why go through all this? I have a Brother HLL3260CDW and the generic driver provided by OM works very well.

1 Like

For me it didn’t. ROME