To capture a website screenshot in Go inside Docker, use chromedp to drive a compatible Chrome or Chromium browser, then save the screenshot bytes somewhere durable. chromedp is the Go client for Chrome DevTools Protocol (CDP), not the browser itself. The chromedp project recommends its chromedp/headless-shell image as the simplest headless setup; it includes a smaller headless Chrome build that chromedp can find out of the box. See the headless-environment guidance.
Choose how Docker will run the browser
You can run the Go program and browser in one image, or run a browser container separately and connect to it over CDP. Neither layout is universally better: the single-image approach keeps the browser local to the program, while a separate browser endpoint can be managed independently but must be reachable and protected on the network.
As an Amazon Associate I earn from qualifying purchases.
One image for the Go program and browser
The chromedp README calls running the Go program inside chromedp/headless-shell the simplest headless route. For a quick experiment, use the project image directly after checking the selected tag’s entrypoint and browser path. For a deployable application, build an image that contains both your Go binary and a compatible browser runtime, or adapt the project image after verifying its behavior. The headless-shell repository describes the image as a multi-architecture container for browser driving, profiling, and testing. Image repository and usage notes.
Separate browser and application containers
Run headless-shell as a browser service and use chromedp’s remote allocator to connect to its DevTools endpoint. The official examples include both a container-oriented multi example and a remote example for an existing Chrome DevTools instance. This separates browser lifecycle from application lifecycle, but also introduces endpoint configuration and network-security responsibilities. Keep the debugging endpoint inside the network boundary that needs it; do not expose it publicly. Official examples.
#1 Best Overall
- 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
Capture a viewport, element, or full page
These chromedp actions produce different results. Choose based on what the consumer needs, rather than treating “screenshot” as one interchangeable operation. The code below assumes the Go program can launch a compatible local Chrome/Chromium executable.
| Desired image | Action | Behavior to account for |
|---|---|---|
| One visible page element | chromedp.Screenshot(selector, &buf, chromedp.NodeVisible) |
Captures a matching visible node as PNG. The query fails if the selector matches no nodes. |
| Current viewport | chromedp.CaptureScreenshot(&buf) |
Captures the browser’s current viewport, not the whole scrollable document. |
| Full-size page | chromedp.FullScreenshot(&buf, 90) |
Captures the full page. In the implementation, quality 100 selects PNG; any other quality selects JPEG. The documented range is 0–100. This action overrides device-emulation settings, so reset emulation if subsequent actions rely on the prior device profile. |
The selector screenshot’s visible-node behavior and PNG output are implementation details; confirm them against the chromedp version you pin. The implementation comments also note that its behavior differs from Chrome DevTools’ element-screenshot UI in commands it does not send. Package API and implementation documentation.
Rank #2
- 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
Runnable Go example: capture a full-page PNG
This example navigates to a URL, waits for a page-specific element, captures the full page, and writes the resulting bytes to a file. Replace the URL and selector with values appropriate to your target site. The selector wait is intentional: navigation by itself does not guarantee that a JavaScript-heavy page has finished rendering the content you need.
package main
import (
"context"
"log"
"os"
"github.com/chromedp/chromedp"
)
func main() {
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
var shot []byte
err := chromedp.Run(ctx,
chromedp.Navigate("https://example.com"),
chromedp.WaitVisible("body", chromedp.ByQuery),
chromedp.FullScreenshot(&shot, 100),
)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("screenshot.png", shot, 0644); err != nil {
log.Fatal(err)
}
}
Initialize a Go module and add chromedp, then build the program with the browser runtime available in the final container. For repeatable builds, pin both the Go module version and the headless-shell image version or browser release. The chromedp repositories’ default branches and floating image tags can change; the headless-shell project says its stable, beta, and dev channel images are refreshed daily. Check the image’s available tags and runtime notes.
Rank #3
- 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.
Change the capture action for another output
- For the current viewport, replace the full-page action with
chromedp.CaptureScreenshot(&shot); write the file with a matching extension such as.png. - For a visible element, use
chromedp.Screenshot(".chart", &shot, chromedp.NodeVisible). If the selector does not match a visible node, the action fails. - For a full-page JPEG at the example quality, use
chromedp.FullScreenshot(&shot, 90)and save it with a.jpgor.jpegextension. Quality 100 selects PNG in the implementation; other values select JPEG.
Build and run the container reliably
Pin the browser runtime
Floating channel tags are convenient but may change from one build to another. Use a specific headless-shell version tag when you need reproducibility, and check the image registry for currently available versions before choosing one. Keep the browser and chromedp versions compatible; the official repositories do not provide a permanent guarantee that arbitrary versions work together.
Wait for the page state you need
A successful navigation does not necessarily mean that delayed images, client-rendered content, or other asynchronous elements are ready. Prefer an explicit condition tied to the page, such as waiting for a known element to become visible or waiting for a known loading indicator to disappear. A fixed sleep may be either too short on a slow run or unnecessarily long on a fast one. The official examples include a visibility-wait example, but do not prescribe one universal readiness rule. Examples index.
Rank #4
- 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
Persist the screenshot beyond container exit
The example writes to the container’s filesystem. If the container may be removed and the image must survive, write to a mounted volume or upload the bytes to your application’s storage layer before the container exits. A container’s writable layer is not a durable storage plan when the container is deleted.
Free tools Windows power users keep installed
One-click scans. No signup required.
Clean up browser processes
Always call the cancellation function returned by chromedp.NewContext; the deferred cleanup in the example handles the normal exit path. The chromedp FAQ says that on Linux it force-kills Chrome child processes to avoid resource leaks. If Chrome must outlive a short-lived Go task, the documented approach is to start Chrome separately and connect with a RemoteAllocator. Chromedp FAQ.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Troubleshoot common Docker and capture failures
- Chrome cannot be found or launched: chromedp is only the CDP client. Make sure the final image contains a compatible Chrome/Chromium runtime or uses the headless-shell image, and verify the selected image tag’s entrypoint and browser path.
- Headless-shell crashes with
BUS_ADRERR: the image documentation recommends increasing shared memory; its example uses--shm-size 2G. Apply this for the documented symptom rather than treating it as a universal setting. Headless-shell container notes. - Zombie processes accumulate: the project recommends Docker’s
--initoption. For older Docker setups, its documentation also showsdumb-initortini. - Chrome fails under a non-root user or security profile: the repository gives an unprivileged
nobodyexample with a Chrome seccomp profile. Match the security configuration to your runtime and image; do not make disabling browser sandbox protections the default fix. - The page screenshot is blank or incomplete: check that the URL loaded, then wait for a site-specific readiness condition before capture. For element capture, confirm the selector matches a visible node.
- The full-page shot no longer uses the intended emulation:
FullScreenshotoverrides device-emulation settings. Reapply the required emulation after the action if later browser operations depend on it. - The output disappears after a run: save the bytes to a mounted volume or external storage rather than relying on a container that will be removed.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF without requiring you to package and operate Chrome for this capture:
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 and removed before capture, along with supported newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers indicate the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan.
Frequently asked questions
Can chromedp take a screenshot without Chrome installed?
No. chromedp drives a browser that supports CDP; it does not supply that browser. Include a compatible runtime in the image or connect to a separately running browser.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Does the full-page screenshot preserve the viewport device emulation?
No. The full-page action overrides emulation settings. Reapply the settings if later actions need them.
Quick Recap
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.




