Mockoon
API mocking tool for development.
Overview
Mockoon is an open-source API mocking tool that enables developers to create realistic mock APIs without writing code. Originally launched as a desktop application, Mockoon has evolved to include a powerful CLI version that can simulate REST APIs with advanced features like templating, response rules, and request proxying. The tool generates HTTP responses based on predefined configurations, making it invaluable for frontend development, API testing, and service integration scenarios. This Docker configuration leverages Mockoon CLI to provide containerized API mocking capabilities that can be easily integrated into development workflows and CI/CD pipelines. The setup mounts local JSON configuration files that define API endpoints, responses, and behaviors, allowing teams to version control their mock definitions alongside application code. The containerized approach ensures consistent mock API behavior across different development environments while eliminating the need for developers to install and configure Mockoon locally. Development teams benefit from this stack when they need to develop against APIs that are still under development, test error conditions, or simulate third-party services without depending on external systems.
Key Features
- JSON-based configuration system that supports version control and team collaboration
- Built-in templating engine with Handlebars support for dynamic response generation
- Advanced routing with wildcard patterns and parameter extraction from URLs
- Response delay simulation to test application behavior under network latency conditions
- Request/response logging and monitoring for debugging API interactions
- OpenAPI specification import for rapid mock API creation from existing documentation
- Proxy mode functionality to forward requests to real APIs while intercepting specific endpoints
- CORS headers configuration for cross-origin request testing in browser applications
Common Use Cases
- 1Frontend development teams building applications before backend APIs are complete
- 2QA engineers testing application error handling by simulating API failures and edge cases
- 3Integration testing environments where third-party APIs need to be mocked for reliability
- 4Development workshops and training sessions requiring consistent API responses
- 5Microservices development where dependent services need to be simulated during testing
- 6Mobile app development requiring offline API simulation during device testing
- 7API contract testing to validate client applications against predefined API specifications
Prerequisites
- Docker Engine 20.10+ and Docker Compose V2 for container orchestration
- Minimum 512MB RAM allocation for Mockoon CLI container operations
- Port 3000 available on host system or alternative port configuration knowledge
- Basic understanding of REST API concepts and JSON structure for configuration
- Mockoon desktop application for creating and exporting API configurations (optional but recommended)
- Familiarity with OpenAPI/Swagger specifications if importing existing API documentation
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 mockoon: 3 image: mockoon/cli:latest4 container_name: mockoon5 restart: unless-stopped6 command: --data /data/api.json7 volumes: 8 - ./mockoon:/data9 ports: 10 - "3000:3000".env Template
.env
1# Create mockoon/api.json with your mock APIUsage Notes
- 1Docs: https://mockoon.com/docs/latest/about/
- 2Create API in Mockoon desktop app, export as JSON
- 3Mount exported JSON at /data/api.json
- 4API available at http://localhost:3000 (configurable)
- 5Supports templating, rules, proxying, and delays
- 6OpenAPI import supported for quick mock creation
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 mockoon:5 image: mockoon/cli:latest6 container_name: mockoon7 restart: unless-stopped8 command: --data /data/api.json9 volumes:10 - ./mockoon:/data11 ports:12 - "3000:3000"13EOF1415# 2. Create the .env file16cat > .env << 'EOF'17# Create mockoon/api.json with your mock API18EOF1920# 3. Start the services21docker compose up -d2223# 4. View logs24docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/mockoon/run | bashTroubleshooting
- Container exits with 'ENOENT: no such file or directory' error: Ensure the mockoon directory exists and contains a valid api.json configuration file
- API endpoints return 404 for all requests: Verify the JSON configuration file contains properly defined routes and the file is correctly mounted at /data/api.json
- Port binding fails with 'port already in use' error: Change the host port in the ports mapping or stop conflicting services using port 3000
- Mock API responses don't match expected format: Validate JSON configuration syntax and ensure Handlebars templating expressions are properly escaped
- Container starts but API is unreachable: Check that the Mockoon configuration specifies the correct port (3000) and host binding (0.0.0.0) for container access
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download