如何在 Docker 容器中 运行 pdfkit from_file

How to run pdfkit from_file in a Docker container

以下是我的 Docker 代码:

FROM python:3.6.2-jessie

## Prepare apt-get:
RUN echo "debconf debconf/frontend select Noninteractive" | debconf-set-selections && \
    apt-get update -qy && \
     apt-get upgrade -qy && \
    apt-get clean autoclean && \
    apt-get install wkhtmltopdf -y && \
    apt-get autoremove -y && \
    apt-get install python3-setuptools -qy &&\
    apt-get install python3-dev -qy && \
    apt-get install python3-pip -qy && \
    apt-get install build-essential -qy && \
    apt-get -y install openssh-client -qy && \
    apt-get clean

RUN pip3 install --upgrade pip
RUN pip3 install pandas
RUN pip3 install psycopg2==2.7.3.2
RUN pip3 install pdfkit

当我运行下面的代码时,

docker run my_image python3 pdfkit.py

我收到以下错误:

OSError: wkhtmltopdf exited with non-zero code -6. error: The switch --viewport-size, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QXcbConnection: Could not connect to display

尝试以下操作:

RUN curl -L#o wk.tar.xz https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz \
    && tar xf wk.tar.xz \
    && cp wkhtmltox/bin/wkhtmltopdf /usr/bin \
    && cp wkhtmltox/bin/wkhtmltoimage /usr/bin \
    && rm wk.tar.xz \
    && rm -r wkhtmltox

而不是直接使用 apt-get install wkhtmltopdf -y 安装。