DockerMock is a Django-based REST API project that provides endpoints for creating, managing, and monitoring Docker containers. It allows users to send JSON data to the server, which is then used to create, run, delete, modify containers, and execute Docker commands. This README provides an overview of the project, installation instructions, and usage examples.
- Create and manage Docker containers via REST API.
- View a list of all created containers.
- Start, stop, and delete containers.
- Retrieve container logs and historical actions.
- Customizable Docker container creation parameters.
Before you begin, ensure you have met the following requirements:
- Python 3.x installed on your system.
- Docker installed and running.
Follow these steps to set up and run the DockerMock project locally:
-
Clone the repository to your local machine:
git clone https://github.com/MostafaMoradi7/dockerMock.git cd DockerMock
-
Create a virtual environment and activate it (optional but recommended):
python -m venv venv source venv/bin/activate
-
Install project dependencies:
pip install -r requirements.txt
-
Apply database migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
-
Your DockerMock API should now be accessible at
http://localhost:8000/
.
To use the DockerMock API, you can send JSON data to the server to create and manage Docker containers. Here's an example of creating a container:
curl -X POST -H "Content-Type: application/json" -d '{"name": "new-container", "image_address": "hub.hamdocker.ir/nginx:1:21", "envs": {"key1": "value1"}, "command": "sleep 1000"}' http://localhost:8000/apps/
For detailed API documentation and endpoints, please refer to the API Endpoints section below.
/api/apps/
(GET): Get a list of created containers./api/apps/
(POST): Post a json to the server and create a docker container./api/apps/<container_id>/
(GET): Retrieve a specific container./api/apps/<container_id>/
(PUT): Update a specific container (NAME must change)./api/apps/<container_id>/
(PATCH): STOP or RUN a specific container./api/apps/<container_id>/
(DELETE): Delete a specific container./api/history/
(GET): List all historical actions.
For more details on request and response formats, refer to the spectaculare documentation in which is available through the api endpoints of the project.
Contributions to DockerMock are welcome! You can contribute by:
- Reporting issues or suggesting improvements by opening issues.
- Submitting pull requests for bug fixes or new features.
- Providing feedback and ideas to enhance the project.
Please follow the Contributing Guidelines for more information.