API Testing with Postman — Run a Collection with Docker
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.yml
file. (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 containersdocker-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! 😄