I use docker to test. I will include my Dockerfile, entrypoint.sh and build commands below.
xhost +local:docker && socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
ff_version=<AS MENTIONED ABOVE>
ff_home=`pwd`/ff-home-${ff_version}
DOCKER_DISPLAY=<IP ADDRESS OF WORKSTATION RUNNING X>:0
mkdir ${ff_home}
#Verify version
docker run --rm --volume ${ff_home}:/home/firefox -e "DISPLAY=${DOCKER_DISPLAY}" -u `id -u` -e 'HOME=/home/firefox' ff:${ff_version} firefox -version
#Setup cmdlnprint after running this next command
docker run --rm --volume ${ff_home}:/home/firefox -e "DISPLAY=${DOCKER_DISPLAY}" -u `id -u` -e 'HOME=/home/firefox' ff:${ff_version} firefox
#Now the actual test
docker run --rm --volume ${ff_home}:/home/firefox -e "DISPLAY=${DOCKER_DISPLAY}" -u `id -u` -e 'HOME=/home/firefox' ff:${ff_version} firefox -print https://google.com -print-mode pdf -print-file /home/firefox/google.pdf
In Firefox 45 I have confirmed that I can print to file in this same environment that cmdlnprint does not work. I printed to /home/firefox/mozilla.pdf and verified that the output was as expected.
I have tested in a similar manner with the same results with CentOS if you need me to prepare Dockerfile for CentOS I can do so but it would require some work to prepare from the version that I have for my solution.
FROM ubuntu:latest
#FROM ubuntu:precise
#For Firefox Version 11 use precise (12.04)
#Ubuntu Current Stable is 16.04 aka xenial aka latest
ENV DEBIAN_FRONTEND noninteractive
ENV RUNUSER firefox
ENV UBUNTU_NICKNAME xenial
#ENV UBUNTU_NICKNAME precise
ARG FIREFOX_VERSION=51
RUN \
useradd -m $RUNUSER && \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_NICKNAME} multiverse" >> /etc/apt/sources.list.d/multiverse.list && \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_NICKNAME}-updates multiverse" >> /etc/apt/sources.list.d/multiverse.list && \
echo "deb http://archive.ubuntu.com/ubuntu/ ${UBUNTU_NICKNAME}-backports restricted universe multiverse" >> /etc/apt/sources.list.d/multiverse.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
dbus-x11 \
firefox=${FIREFOX_VERSION}* \
ttf-mscorefonts-installer \
xvfb && \
rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /tmp/entrypoint.sh
RUN chmod 755 /tmp/entrypoint.sh
ENTRYPOINT ["/tmp/entrypoint.sh"]
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
DISPLAY=${DISPLAY-}
FB_DIR=${FB_DIR-/tmp/bigchart-fb}
FB_RESOLUTION=${FB_RESOLUTION-1024x768}
FB_PIXEL_DEPTH=${FB_PIXEL_DEPTH-24}
if [[ -n ${DISPLAY} ]]; then
echo "DISPLAY already set to ${DISPLAY}. Skipping Xvfb setup."
else
echo "Setting up Xvfb in ${FB_DIR}"
Xvfb :1 -screen 0 ${FB_RESOLUTION}x${FB_PIXEL_DEPTH} -fbdir ${FB_DIR} 2>&1 | \
egrep -v '^(_XSERVTransmkdir.*will not be created\.|Xlib: extension "RANDR" missing on display .*\.)$' &
export DISPLAY=":1"
fi
exec "$@"
docker rmi ff:11 ff:45 ff:51
docker build --build-arg FIREFOX_VERSION=45 -t ff:45 ./ &&
docker build --build-arg FIREFOX_VERSION=51 -t ff:51 ./ &&
sed -i.orig -E -e 's,^(FROM ubuntu:|ENV UBUNTU_NICKNAME ).*,\1precise,' Dockerfile &&
docker build --build-arg FIREFOX_VERSION=11 -t ff:11 ./
mv Dockerfile.orig Dockerfile