Use Docker Compose to define your app and its dependencies once, then apply only the staging-specific differences with profiles or an override file. For repeatable web testing, start an isolated stack, wait until its dependencies are ready, run the tests, and remove the stack afterward. Docker Docs says Compose works in production, staging, development, testing, and CI workflows (Docker Compose).
What a Docker staging environment should include
A staging environment is a deployment target configured to exercise the application in conditions closer to its intended use than a developer-only setup. It can run locally for automated or individual testing, or on a remote Docker host when teammates and testers need a shared preview URL. The required services depend on the app: commonly a web service plus a database, cache, or queue.
Compose keeps those services and their configuration in an application model. Containers on the Compose network can find one another by service name, so the web service should connect to a database using its Compose service name rather than a container IP address, which can change.
Create a shared Compose base
Start with your application source and Dockerfile, then add a compose.yaml. This illustrative configuration has a web app and PostgreSQL database. Replace the image, build details, database settings, and health-check command to match your application and database version; the health-check command shown uses the PostgreSQL image’s pg_isready utility.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
services:
web:
build: .
ports:
- "${WEB_PORT:-8000}:8000"
environment:
DATABASE_HOST: db
DATABASE_NAME: app
DATABASE_USER: app
depends_on:
db:
condition: service_healthy
db:
image: postgres:16
environment:
POSTGRES_DB: app
POSTGRES_USER: app
POSTGRES_PASSWORD: local-only-change-me
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app -d app"]
interval: 5s
timeout: 3s
retries: 10
This example is a starting point, not a production credential pattern: do not commit real passwords or pass sensitive values through ordinary environment variables. Docker recommends secrets for sensitive data. Keep staging credentials and data separate from production, and configure the app to consume secrets using the approach supported by your application and deployment.
Choose how to express staging differences
Docker’s FAQ says teams do not necessarily need entirely separate Compose files for development, testing, and staging. Use a profile when staging primarily enables a group of optional services; use an override when staging changes settings on services already in the base file. Both approaches can be inspected with docker compose config.
| Approach | Best fit | How to review it |
|---|---|---|
| Profiles in one file | Enabling or disabling groups of services, such as an optional monitoring service. | Run Compose with the selected profile, then inspect the resolved output using docker compose config. |
| Base plus override file | Changing settings such as ports, environment configuration, or restart behavior while keeping the common service model. | List files in order with -f, then use docker compose config to see the merged result. |
Option A: profiles for optional services
Add a profile to services that should run only in staging. For example:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
services:
web:
build: .
ports:
- "8000:8000"
metrics:
image: example/metrics
profiles: ["staging"]
Start the staging-profile services with docker compose --profile staging up -d. A profile is a good fit for optional services; it is less direct when the same service needs substantially different configuration in each environment.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Option B: a staging override
Keep common configuration in compose.yaml and put only staging changes in compose.staging.yaml. For example, a staging-specific port and restart policy can be expressed as:
services:
web:
ports:
- "8080:8000"
restart: unless-stopped
Apply both files in order:
docker compose -f compose.yaml -f compose.staging.yaml config
docker compose -f compose.yaml -f compose.staging.yaml up -d
Compose merges files in the order listed; later files add to or override earlier settings. Relative paths in merged files are resolved from the first Compose file, so a file in a subdirectory does not make its relative paths relative to that subdirectory.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Make staging representative without exposing development shortcuts
Change only what staging needs: host ports, service settings, logging, restart behavior, or optional observability services. When test fidelity matters, avoid development conveniences that let the host alter the running app unexpectedly. Docker’s production guidance specifically calls out removing application-code bind mounts so code remains in the image rather than being changed from outside; the same principle can improve staging fidelity.
- Build the application image from the version of the code under test.
- Use service names for internal connections, such as
dbfor the database hostname. - Keep production credentials and data out of staging.
- Expose only the ports and services testers need, using your organization’s access controls for any shared environment.
Start, inspect, test, and remove the stack
- Validate the effective settings:
docker compose config, or include the staging files and profile you intend to use. - Start the environment in the foreground with
docker compose up, or in the background withdocker compose up -d. For an override, include both-f compose.yaml -f compose.staging.yaml. - Check service state with
docker compose ps. Follow startup output withdocker compose logs -f. - Run a check inside a running service with
docker compose exec web COMMAND, replacingCOMMANDwith an app-specific health or diagnostic command. - Run the test suite against the app’s published test URL or configured endpoint. For an isolated test stack, remove it after the tests with
docker compose down.
For automated runs, create the stack, run tests, and tear it down even when a test fails. In shell scripts or CI, put teardown in a cleanup/finally step so failed tests do not leave containers behind. If the run uses a project name, use that same name on down.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteIsolate parallel branches and CI jobs
Compose project names group a stack’s resources. Give each simultaneous branch environment or CI job a unique name using -p, or set COMPOSE_PROJECT_NAME. For example:
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
docker compose -p "webtest-${BUILD_ID}" up -d
docker compose -p "webtest-${BUILD_ID}" ps
docker compose -p "webtest-${BUILD_ID}" down
Substitute a unique build identifier supplied by your CI system. Without unique names, concurrent runs can contend for project resources, especially if they define the same services or host ports. Host ports must also be unique when stacks bind to the same machine; alternatively, avoid publishing a port that the test runner does not need.
Choose local or remote staging
| Where it runs | Useful when | Considerations |
|---|---|---|
| Local machine or CI worker | Automated tests or individual checks need a disposable, repeatable stack. | Keep project names unique for concurrent runs and clean up after testing. |
| Remote Docker host | Teammates or testers need a shared staging deployment reachable beyond one developer’s machine. | Decide who owns the host and how credentials, network exposure, and access are controlled. Docker documents remote-host configuration, but does not prescribe a provider or organization-wide security design. |
Docker’s remote-host guidance describes connecting through environment variables including DOCKER_HOST, DOCKER_TLS_VERIFY, and DOCKER_CERT_PATH. Set these for the secured remote Docker endpoint provided by your administrator; do not expose an unauthenticated Docker daemon to the public internet.
Troubleshoot common staging failures
- The web container starts before the database accepts connections:
depends_onby itself controls startup order, not readiness. Add a health check and use the healthy dependency condition where supported; also configure the app to retry transient connection failures if appropriate. - The app cannot resolve the database: use the Compose service name as the hostname, not a fixed container IP, and confirm the services are in the same Compose project/network.
- A port is already allocated: another process or parallel stack is using the host port. Change the staging host-side port, stop the conflicting process, or avoid publishing the port if only containers need it.
- An override does not take effect: confirm the exact files and their order in the command, then inspect the merged result with
docker compose -f compose.yaml -f compose.staging.yaml config. - A relative build or file path fails after adding an override: merged-file paths are resolved from the first Compose file. Adjust the path relative to that base file.
- One CI run affects another: use a distinct project name for each run and use matching names when inspecting or removing each stack.
- Staging changes unexpectedly when source files change: remove development bind mounts when staging should test the code baked into the image.
- Credentials appear in configuration or logs: remove sensitive values from checked-in files and ordinary environment variables, rotate exposed credentials, and use Docker secrets or an appropriate secret-handling mechanism.
Or skip the browser setup
If your web tests need screenshots of the staging URL, ScreenshotNeo can capture a page with one GET request. For a PNG, JPEG, or WebP response:
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://staging.example.com -o shot.webp
See the ScreenshotNeo API docs for request options. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; those steps can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. An MCP server provides screenshot tools for AI agents, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.
FAQ
Does Compose support staging as well as testing?
Yes. Docker Docs describes Compose as usable across production, staging, development, testing, and CI workflows.
Do I need a separate complete Compose file for every environment?
No. A shared base with profiles or ordered override files can capture differences without maintaining a full duplicate stack definition.
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.
Recommended Free Tools

