TheTom
TheTom

Reputation: 1054

Docker Wkhtmltopdf HostNotFoundError

As I try to run wkhtmltopdf (v 0.12.5) inside a docker container (which works fine if I try to generate a pdf from external url (http://google.de), I'm getting this error:

wkhtmltopdf http://app.local/web/app_dev.php/get/media media.pdf Loading pages (1/6) Error: Failed to load http://app.local/web/app_dev.php/get/media, with network status code 3 and http status code 0 - Host app.local not found Error: Failed loading page http://app.local/web/app_dev.php/get/media (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: HostNotFoundError

I guess the problem is, that the container itself doesn't know about the /etc/hosts entry which I added on my local machine

127.0.0.1 app.local

I'm confused and stuck because I don't know how to solve this. I use symfony, but that doesn't really matter, as I get the error above when I use it inside the container itself by docker exec -it bash. Runnin the script without docker works fine.

Can anyone provide me a solution or a hint how to get this runnin'?

Upvotes: 1

Views: 2680

Answers (1)

atline
atline

Reputation: 31584

You can add host to containers' /etc/hosts using --add-host, see this.

Something like:

$ docker run -it --add-host db-static:86.75.30.9 ubuntu cat /etc/hosts
172.17.0.22     09d03f76bf2c
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
86.75.30.9      db-static

Upvotes: 2

Related Questions