Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use wkhtmltopdf with Docker

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

(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)

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

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

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

like image 854
Martin Thoma Avatar asked Sep 25 '17 07:09

Martin Thoma


1 Answers

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.

like image 155
Martin Thoma Avatar answered Oct 22 '22 09:10

Martin Thoma