如何在Docker中使用wkhtmltopdf [英] How to use wkhtmltopdf with Docker

查看:1077
本文介绍了如何在Docker中使用wkhtmltopdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Docker容器中使用wkhtmltopdf(0.12.2.4版,通过apt-get安装)时,它失败了,

When I use wkhtmltopdf (version 0.12.2.4, installed via apt-get) within a Docker container it fails with

QXcbConnection: Could not connect to display

(当我设置环境变量 DISPLAY时= unix0 ,我得到 QXcbConnection:无法连接以显示unix0 ,这很有意义,因为似乎未安装Xserver)

(When I set the environment variable DISPLAY=unix0, I get QXcbConnection: Could not connect to display unix0 which makes sense as no Xserver seems to be installed)

似乎有一个无头版本(),我认为那意味着我不需要Xserver。

There seems to be a headless version (source) and I thought that would mean that I don't need an Xserver.

xvfb 似乎是另一种选择,但我不确定如何运行它/如何安装)

(xvfb seems to be another option, but I'm not sure how to run it / what to install)

如果无法将基本映像更改为<$ c,如何在Docker容器中运行wkhtmltopdf $ c> openlabs / docker-wkhtmltopdf ?

How can I run wkhtmltopdf in a Docker container, if I can't change the base image to openlabs/docker-wkhtmltopdf?

推荐答案

安装版本 0.12.4 (我之前有 0.12.2.2 )解决了问题米有关步骤,请参见如何在Ubuntu 16.04上安装最新的wkhtmltopdf?

Installing version 0.12.4 (I had 0.12.2.2 before) solved the problem. See How can I install the latest wkhtmltopdf on Ubuntu 16.04? for the steps.

这篇关于如何在Docker中使用wkhtmltopdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆