Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a container image that already includes wkhtmltopdf, pass the input and output paths as arguments, and bind-mount a host directory when the PDF must survive container removal. A typical run is:

docker run --rm 
  -v "$PWD:/data" 
  <image>:<pinned-tag> 
  https://example.com /data/output.pdf

This works only when the image entrypoint invokes wkhtmltopdf and accepts its normal arguments. Check the image documentation or run its version command first. For production, pin a maintained tag or digest, verify the Qt build, install the fonts your pages need, and test representative documents before changing versions.

What runs inside the container

wkhtmltopdf is a headless command-line renderer that converts HTML pages to PDF with Qt WebKit; it does not require an X display or display service. The upstream project repository is archived and read-only as of January 2, 2023, and its separate packaging repository is archived as of August 28, 2023. Treat the binary and any Docker image as legacy dependencies: record the exact versions, review maintenance history, and regression-test output.

A container has its own filesystem. Files written there disappear when the container is removed unless you write into a bind mount or capture the process output on the host. Images are not interchangeable: entrypoints, wkhtmltopdf versions, patched-Qt features, libraries, fonts, architectures and command conventions differ.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Choose and verify an image

Check the rendering build

The packaging documentation explains that patched Qt is used to provide additional wkhtmltopdf functionality. Run the image’s version command and confirm the reported Qt/build details match the features your application needs. Do not assume a distribution package and a patched-Qt build render the same page.

Pin version and architecture

Use a concrete tag or digest rather than an unpinned latest tag. Confirm that the image supports your deployment architecture; an image that works on one host may require emulation or a different build elsewhere. The packaging project documents Docker builds and architecture-specific packaging.

Inspect what the image contains

Determine whether the image is a one-shot command image or a base image, what its entrypoint is, and whether it includes only wkhtmltopdf or also wkhtmltoimage and supporting libraries. Surnet’s published variants distinguish a smaller edition from a full edition that includes wkhtmltoimage and libraries; its tags encode base-image, wkhtmltopdf and edition information. Check the maintainer’s current tag list because availability can change.

Account for fonts

Fonts are part of rendering, not a cosmetic afterthought. Missing fonts alter glyph widths, line breaks and pagination. Include the required font packages in the image and generate a test PDF inside the target container. Surnet’s example Dockerfile explicitly installs fonts for this reason.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run a URL and save the PDF on the host

  1. Create a working directory and place the output there:

    mkdir -p wkhtml-job
    cd wkhtml-job
  2. Run the image with the current directory mounted at /data:

    Rank #2
    Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
    • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
    • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
    • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
    • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
    • The available storage capacity may vary.
    docker run --rm 
      -v "$PWD:/data" 
      <image>:<pinned-tag> 
      https://example.com /data/output.pdf
  3. Confirm the result on the host:

    ls -lh output.pdf
    file output.pdf

The destination must be the container path (/data/output.pdf), not merely the host path. The bind mount maps that container path back to your working directory. If the image has a different entrypoint, invoke the binary explicitly:

docker run --rm 
  -v "$PWD:/data" 
  <image>:<pinned-tag> 
  wkhtmltopdf https://example.com /data/output.pdf

Use the form that the image documents; adding wkhtmltopdf to an image whose entrypoint already supplies it can produce an invalid command.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture PDF bytes through standard output

Some images accept a hyphen as the output filename and write the PDF to standard output. Redirect that stream on the host:

docker run --rm 
  <image>:<pinned-tag> 
  https://example.com - > output.pdf

Keep diagnostic messages on standard error so they do not corrupt the PDF stream. This method avoids a bind mount, but it depends entirely on the image’s documented argument convention. Verify the downloaded file with file output.pdf and open it with a PDF parser before using it in an automated pipeline.

Use a local HTML file

Mount the project directory and refer to the HTML by its container path:

docker run --rm 
  -v "$PWD:/data" 
  <image>:<pinned-tag> 
  /data/index.html /data/index.pdf

Relative CSS, images and fonts must be readable from inside the container. If the document references host-only paths, localhost services or private DNS names, those addresses may not exist from the container’s network namespace. Make assets available through mounted files or a reachable URL, and test with the same network settings used in deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
WD 2TB Elements Portable External Hard Drive for Windows, USB 3.2 Gen 1/USB 3.0 for PC & Mac, Plug and Play Ready - WDBU6Y0020BBK-WESN
  • High capacity in a small enclosure – The small, lightweight design offers up to 6TB* capacity, making WD Elements portable hard drives the ideal companion for consumers on the go.
  • Plug-and-play expandability
  • Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
  • SuperSpeed USB 3.2 Gen 1 (5Gbps)

Build an image you control

A project-owned image should install a compatible wkhtmltopdf build and all required runtime libraries, put the executable on PATH, and set an entrypoint such as wkhtmltopdf. The packaging project documents Docker as a build method and builds from the wkhtmltopdf source tree with Qt. There is no universal safe apt-get install wkhtmltopdf recipe: distribution packages and patched-Qt builds can differ in capabilities and output.

A minimal structure is:

FROM <approved-base-image>
# Install the pinned wkhtmltopdf package or copied binary,
# required shared libraries, and application fonts.
COPY fonts/ /usr/local/share/fonts/
RUN fc-cache -f
ENTRYPOINT ["wkhtmltopdf"]

Replace the placeholders with packages appropriate to your base OS and target architecture. Record the package checksum or image digest in your build process. Build a smoke-test PDF during CI so a missing library or font fails before deployment.

Image-selection checklist

Decision What to verify Why it matters
wkhtmltopdf/Qt variant Version output and whether patched Qt is present Features and rendering can differ between builds.
Tag and architecture Pinned tag or digest and supported CPU architecture Floating tags and incompatible binaries undermine reproducibility.
Entrypoint Whether arguments begin with a URL, HTML path or an explicit binary The same docker run command is not portable across images.
Runtime contents Shared libraries, fonts, wkhtmltoimage, and whether it is a base or one-shot image Missing dependencies cause startup errors or layout changes.
Maintenance Registry update history, source repository and base-image status Old images may contain unpatched operating-system components.

The openlabs Docker Hub page still documents bind-mounted output, but its page reports an update almost 11 years before it was accessed. That is a maintenance warning, not a recommendation.

Reliable production operation

Make inputs deterministic

  • Pin the image tag or digest and record the wkhtmltopdf and Qt versions.
  • Bundle or install the exact fonts used by your templates.
  • Use stable asset URLs or mount the complete HTML asset tree.
  • Run the same architecture and network policy in CI and production.

Validate output

Check the process exit status, file existence and non-zero size. Parse the PDF or render a page image in CI to detect blank output, changed pagination or missing glyphs. Keep representative pages that exercise images, web fonts, JavaScript and long tables.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Control resource use

Apply container CPU, memory and timeout limits appropriate to your workload. Large pages, many images and complex scripts consume more memory than a simple document. A failed or timed-out process should leave no partial file in the location consumed by downstream jobs; write to a temporary name and rename only after validation.

Troubleshooting

No PDF appears on the host

Confirm that the output path is inside the mounted directory and that the mount is writable. Inspect the container command and entrypoint; the image may have written to a different path or emitted bytes to standard output. Run docker inspect on the image to review its configured entrypoint and command.

“No such file or directory” or shared-library errors

The binary or one of its runtime libraries is absent for the image architecture. Run the documented version command, inspect the image contents, and choose a complete variant or rebuild with the required libraries. Do not copy a binary built for a different base image without checking its dependencies.

Blank PDF or failed navigation

Test the URL from inside the container. Verify DNS, proxy settings, certificates, authentication and firewall rules. For local files, check that every CSS, image and font path is accessible under the mounted container path. A bot check or login page can also produce an apparently blank result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Layout, pagination or glyphs changed

Compare the wkhtmltopdf and Qt build, installed fonts, locale, architecture and input assets with the known-good environment. Pin the previous image and run the same regression corpus before accepting an upgrade.

Standard-output capture is corrupted

Ensure the image really supports - as its output argument and that only PDF bytes go to standard output. Redirect standard error separately when diagnosing:

docker run --rm <image>:<pinned-tag> 
  https://example.com - 2>wkhtmltopdf.log >output.pdf
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your requirement is simply a clean screenshot or PDF from a URL, ScreenshotNeo provides a hosted API instead of maintaining a browser-rendering container. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and whether it was billed. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

One request returns PNG, JPEG, WebP or PDF:

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://stripe.com 
  -o shot.webp

See the ScreenshotNeo documentation for all options, including full-page capture with lazy-image loading, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper size/margins/landscape/page ranges, custom CSS and JavaScript, clicks, selector hiding, selector or network-idle waits, request and resource blocking, headers/cookies/user agent/Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python

import requests
r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
await Bun.write('shot.webp', res);

Every feature is available on every plan: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to get an API key.

Best Value
Sale
UnionSine 1TB Ultra Slim Portable External Hard Drive HDD-USB 3.0
  • 【Upgraded version】 - The mirror logo strip is combined with the striped non-slip design. The rounded corners of the shell are more suitable for holding. The strips play a heat dissipation function to ensure a stable and fast transmission process.
  • 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
  • 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
  • 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
  • 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.

Frequently asked questions

Does wkhtmltopdf need Chrome or an X server in Docker?

No. It is a headless Qt WebKit command-line tool, so a display service is not required.

Should I use a floating Docker tag?

No. Pin a concrete tag or digest and keep a regression PDF set for upgrades.

Can a container read a file on my laptop without a volume?

No. Mount the directory containing the file, then use its container path in the wkhtmltopdf command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When is stdout preferable to a bind mount?

Use stdout when the selected image documents PDF streaming and your pipeline can safely redirect and validate the bytes; otherwise a bind mount is clearer and easier to inspect.

Frequently Asked Questions

Which path should I use for the output PDF?

Use a path inside the bind-mounted directory, such as /data/output.pdf; the corresponding host file appears in the mounted host directory.

Why do two wkhtmltopdf images produce different pagination?

Their Qt builds, fonts, libraries, versions, locales or architectures may differ. Compare those components and pin the image that passes your regression tests.

How can I keep a failed conversion from replacing a valid PDF?

Write to a temporary filename, check the exit status and PDF contents, then rename it atomically after validation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
Bestseller No. 2
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
SaleBestseller No. 3

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.