Docker is a platform for building and running applications in a virtual environment. You can use Newman to run your Postman Collections in a Docker container. When running collections in Docker, you can use all available Newman command options and run local collection files.
To use Newman with Docker for macOS or Ubuntu, do the following:
Make sure Docker is installed and running on your system. Go to Get Docker, choose your operating system, and follow the instructions.
To test your Docker installation, run the following command:
docker run hello-world
Pull the Newman Docker image from Docker hub:
docker pull postman/newman;
Run Newman commands on the image. For example, to run a collection, use the collection ID and your Postman API key:
To get the collection ID, select a collection in the sidebar. Select the information icon and copy the ID.
To get an API key, go to Generate a Postman API key.
docker run -t postman/newman run "https://api.getpostman.com/collections/<collection-id>?apikey=<your-api-key>"
The collection runs in Newman, and the output displays in the terminal.
The entry point to the Docker image is Newman, so you can use all Newman command line parameters. You can also run locally stored collection files. The Newman Docker documentation describes how to mount shared data volumes.
To learn more about using Newman with Docker on Windows, go to Using the Newman Docker Image in Windows.
For more information about running Postman Collection runs, see the following:
Last modified: 2024/09/16