The goal of this project was to create a Python server running Flask to act as an RESTful API for controlling a swarm of docker containers, allowing the users to carry out the following commands through the API.
-
GET /containers - List all containers
-
GET /containers?state=running - List running containers (only)
-
GET /containers/<id> - Inspect a specific container
-
GET /containers/<id>/logs - Dump specific container logs
-
GET /images - List all images
-
POST /images - Create a new image
-
POST /containers - Create a new container
-
PATCH /containers/<id> - Change a container's state
-
PATCH /images/<id> - Change a specific image's attributes
-
DELETE /containers/<id> - Delete a specific container
-
DELETE /containers - Delete all containers (including running)
-
DELETE /images/<id> - Delete a specific image
-
DELETE /images - Delete all images
-
Initialise the manager instance by running: 'docker swarm init'.
-
Join the workers to the swarm by running: 'docker swarm join --token' followed by the token supplied by the manager
-
Run DockerCMS.py, it is the server managing all of the API endpoints, executing the required code for each command and returning the relevant results to the user.
-
Create multiple replicas by running: 'docker service create --replicas 5 -p 80:80 --name web nginx' on the manager. The status can be viewed on the visualizer.
-
cmsTester is a batch file designed to test each feature of DockerCMS.py using curl commands. Some tests will run automatically, for others it will ask for input of IDs or states to change, the ids can be taken from the previous commands output.