QAAnywhere

Remote QA & testing jobs, worldwide.

Guides

Docker for testers: reproducible environments without the mystery

By Denis Bojkovski, Test Automation Architect · Published November 25, 2026

What it gives a tester

Docker was mentioned in 15 of the 86 full descriptions on QAAnywhere on 25 November 2026, Kubernetes in 10. You seldom need to design images. You need to start a system, look inside it, reset it, and reproduce a failure in the environment where it happened.

Five ideas

  1. An image is a packaged filesystem; a container is a running copy of it.
  2. Containers are disposable. Anything not in a volume disappears with them.
  3. A volume keeps data.
  4. Containers on one network reach each other by service name, not localhost.
  5. A port mapping 8080:80 means your machine's 8080 leads to the container's 80.

The fourth causes more wasted hours than any other. Inside a container, localhost is the container itself.

Commands you will use weekly

docker ps                     # what is running
docker logs -f api            # follow its output
docker exec -it api sh        # look inside
docker inspect api            # environment, network, mounts
docker compose up -d --wait   # start, wait for health
docker compose down -v        # stop, and delete its volumes

Read down -v twice: it deletes the data. That is what you want for tests, and not what you want on somebody's development database.

An application and its database

services:
  db:
    image: postgres:17
    environment:
      POSTGRES_PASSWORD: test-only
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 2s
      retries: 15
  api:
    build: .
    environment:
      DATABASE_URL: postgres://postgres:test-only@db:5432/postgres
    ports: ['8080:8080']
    depends_on:
      db:
        condition: service_healthy

Without the health check, depends_on waits only for the database container to start, not for the database to accept connections. That gives a suite which fails on the first run and passes on the second.

Databases for tests

Starting a new database per run removes a whole class of stale-data failures. Testcontainers libraries do it from test code, in C#, Java, Python, JavaScript and others, choosing a free port and removing the container afterwards. Share one container across a run, and give each test its own rows or its own schema.

When it fails only in the container

Compare, in order:

  • Versions: print the browser, runtime and application version at the start of every run.
  • Time zone and locale: containers are usually UTC. Set TZ explicitly.
  • Fonts: missing ones shift layouts and break screenshot comparisons.
  • Memory: check with docker stats; an exit code of 137 often means the process was killed, frequently for lack of memory.
  • Shared memory: browsers may need --shm-size or --ipc=host.
  • Case sensitivity: Linux distinguishes Login.ts from login.ts; Windows and macOS usually do not.
  • Processor type: an image built for ARM can behave or perform differently on x86.

Pin versions

postgres:latest means "whatever existed when you last pulled". Use a specific tag, and update it on purpose in a reviewed change, so a failure can be tied to that change.

Practise

Take any application with a database. Write a compose file, run one API test against it, destroy everything, and do it again with a single command. Then stop the database in the middle of a test and watch what the application does: a message or a hang? Failure behaviour is testable once you can control the parts. See GitHub Actions for test automation for running the same file in CI.

Open remote QA roles

  1. QA Engineer (Manual Testing)Velixo · Poland
  2. Quality Analyst (healthcare programs)General Dynamics Information Technology · United States
  3. Marathi Audio Transcription QAWelocalize · India
  4. Bengali Audio Transcription QAWelocalize · India
  5. Quality Analyst (healthcare programs)Gdit · Any Location / Remote

More guides