Mockingbird is a powerful tool for creating and managing mock API environments. This guide will help you get started with the Docker version of Mockingbird, focusing on creating, cloning projects, and managing mock servers via the API.
If you are new to Mockingbird we recommend you to start by using Mockingbird app and reading the first guide
Prerequisites
Ensure that you have Docker installed.
Step 1: Pull the Mockingbird Docker Image
Start by pulling the Mockingbird Docker image from Docker Hub:
docker pull ozkeisar/mockingbird:latest
Step 2: Run the Docker Container
Run the Docker container using the following command:
docker run -d -p 1512:1512 --name mockingbird ozkeisar/mockingbird
This command will:
- Start the Mockingbird container in detached mode (
-d
). - Map port 1512 of your local machine to port 1512 of the container (
-p 1512:1512
). - Name the container "mockingbird" (
--name mockingbird
).
Step 3: Access the API Documentation
You can access the Swagger documentation to explore the API at:
http://localhost:1512/api-docs
Step 4: Create and Clone Projects Using the API
4.1. Create a Project
To create a new project, use the /project/create
endpoint. Send a POST request with the following JSON body:
{
"projectName": "your_project_name"
}
4.2. Clone a Project via SSH
To clone a project using SSH, use the /project/clone/ssh
endpoint. Send a POST request with the following JSON body:
{
"projectName": "your_project_name",
"sshUrl": "git@github.com:user/repository.git"
}
4.3. Clone a Project via HTTPS
To clone a project using HTTPS, use the /project/clone/https
endpoint. Send a POST request with the following JSON body:
{
"projectName": "your_project_name",
"httpsUrl": "https://github.com/user/repository.git",
"username": "your_username",
"password": "your_password"
}
4.4. Open an Existing Project
To open an existing project, use the /project/open
endpoint. Send a POST request with the following JSON body:
{
"projectName": "your_project_name",
"directoryPath": "/path/to/your/project"
}
Step 5: Start and Close the Mock Server
5.1. Start the Mock Server
To start the mock server for a specific project, use the /servers/start
endpoint. Send a POST request with the following JSON body:
{
"projectName": "your_project_name"
}
Note: Exposing Mock Server Ports
When starting mock servers, ensure that you expose the ports used by these servers so they can be accessed externally. You can do this by adding additional
-p
flags when running the Docker container. For example, if your mock server runs on port 4000, include-p 4000:4000
in your Docker run command.
5.2. Close the Mock Server
To close the running mock server, use the /servers/close
endpoint. Send a POST request without any body:
Step 6: Stopping and Removing the Container
To stop the running Mockingbird container, use:
docker stop mockingbird
To remove the container entirely, run:
docker rm mockingbird
Follow us on social media
Follow us on X(Twitter).
Follow us on Threads.
Top comments (0)