October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Run PhantomJS Screenshots in a Docker Container

Use a PhantomJS script and a Docker bind mount to save screenshots to your host, while checking compatibility carefully because PhantomJS and its commonly surfaced image are legacy.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a webpage with PhantomJS in Docker, write a JavaScript script that opens the URL and calls page.render(), then run that script inside a PhantomJS container with the output directory mounted to the host. Set viewportSize for the browser window and clipRect if you need to crop the result. The important caveat: PhantomJS development is suspended, its upstream repository is archived, and the commonly surfaced wernight/phantomjs image is old. Treat this as a legacy workflow and verify image availability and compatibility before relying on it. PhantomJS Archived repository Docker Hub image

Write a PhantomJS screenshot script

Save this as capture.js. Replace the example URL if needed. The script sets a 1024 × 768 browser viewport, opens the page, writes a PNG, and exits after the page-open callback runs.

As an Amazon Associate I earn from qualifying purchases.

var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };
page.open('https://example.com/', function (status) {
  if (status !== 'success') {
    console.log('Unable to load the page');
    phantom.exit(1);
    return;
  }
  page.render('/output/capture.png');
  phantom.exit();
});

The status check gives a nonzero exit when PhantomJS reports that it could not open the page. It does not guarantee that a site has finished all client-side rendering or that every image has loaded; PhantomJS’s documented basic pattern is to render after page.open calls back. See the PhantomJS screen-capture guide.

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

Run the script in Docker and keep the output

First check that the image tag exists for your platform and that it can run in your environment. Docker Hub’s wernight/phantomjs listing shows a 2.1.1 tag and Docker usage examples, but the listing says it was updated almost six years ago. The following command illustrates the bind mount and working-directory arrangement; it is not a claim that the old image is currently available or compatible on every host.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
  1. Create a local directory for the script and output, for example phantom-job, and place capture.js inside it.

  2. Run the container with that directory mounted at /output:

    docker run --rm -v "$PWD/phantom-job:/output" -w /output wernight/phantomjs:2.1.1 phantomjs capture.js
  3. After a successful run, look for capture.png in the host’s phantom-job directory. If your verified image uses a different tag or command layout, adjust the image reference or invocation accordingly.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    Rank #2
    Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
    • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
    • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
    • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
    • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
    • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

The Docker Hub listing documents the image and tags, but the exact mount path and working-directory arrangement above are tailored to this example. Check the image listing before using it, especially on a different CPU architecture or with a custom build.

Choose the viewport, crop, and output format

Viewport and clipping are different

page.viewportSize sets the headless browser’s viewport dimensions, which affect layout and responsive breakpoints. page.clipRect selects a rectangle of the rendered page to capture; it does not set the viewport. For example, add this before opening the page to capture a 600 × 400 rectangle starting at the top-left:

page.clipRect = { top: 0, left: 0, width: 600, height: 400 };

Choose viewport dimensions that match the layout you need, then use clipping only when the output should be restricted to a particular region. Both settings are documented in the screen-capture guide.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

File extension determines the format

PhantomJS selects the render format from the output filename extension. The render API documentation lists PDF, PNG, JPEG, BMP, and PPM; GIF depends on the Qt build. For instance, use page.render('/output/capture.jpg') for JPEG. An extension does not establish that every format will work in every build, so verify the result with the image or document tools in your environment.

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

Background and headless operation

The PhantomJS FAQ says the rendered output can have a transparent background when the page does not set one. If you need an opaque background, set one deliberately in the page or script and check the resulting file. The FAQ also says PhantomJS versions 1.5 and later are pure headless and do not require X11 or Xvfb. PhantomJS FAQ

Know the legacy and security trade-offs

The PhantomJS project website says development is suspended, and GitHub marks the upstream repository archived and read-only; GitHub gives the archive date as May 30, 2023. The repository describes 2.1 as the latest stable release. The Docker Hub image’s stale update status adds a separate maintenance concern: old browser code and an old container image may not suit current security or platform requirements. Project notice Repository status Image listing

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Keep this setup only when its legacy rendering behavior is necessary and its compatibility is acceptable for your workload. Before adopting it, verify the image tag, CPU architecture, Docker invocation, and output on the actual host. The documentation and registry listing establish the historical workflow, not a successful current build or screenshot test.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

Or skip the browser setup

ScreenshotNeo takes a screenshot through one GET request, returning PNG, JPEG, WebP, or PDF. For example, this cURL call saves a WebP capture of the target URL:

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

See the ScreenshotNeo API documentation for the request options. Cookie and consent banners are accepted like a visitor and removed along with more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response reports the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try it with 1,000 screenshots a month and no card.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.