API Testing with Postman — Run a Collection with Docker

Michael Montgomery
assert(QA)
Published in
1 min readSep 2, 2020

--

Docker Compose 🖌

Compose is a tool for defining and running multi-container Docker applications, providing us more control over those containers configuration and easily stored in a docker-compose.ymlfile. (Source: Docker documentation)

Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.

Create a file called docker-compose.yml in your project directory and paste the following:

version: "3"
services:
postman_collection:
container_name: postman_docker_container
build: .
image: postman_docker_image
command:
run https://www.getpostman.com/collections/f4647fd6257e8af43303
--folder "Environment Variables Example"
-r html,cli
--reporter-html-export reports/Main_Report.html
volumes:
- ./src:/etc/newman

Now we have

  • Dockerfile to configure our containers
  • docker-compose.yml containing our build instructions for our Docker container

Next, rundocker-compose up to run our Docker container!

With a single command, we can create and start all the services from our configuration!

From here, we can now specify all the Docker options we want in our docker-compose.yml and enable anyone to run from their machine!

It’s a great option for a CI/CD pipeline or if someone wants to run your collection without needing to install local dependencies.

😄 Hope this was helpful and happy testing! 😄

--

--