Simplifying Docker Host Management with DockerComposeAPI
391
DockerComposeAPIThis application is designed to interact with docker-compose commands using RESTful APIs. It allows users to run docker-compose commands, and view the output.
docker-compose commands.
To run the application, follow these steps:
Pill the Docker image:
docker pull senaddizdarevic/docker-compose-api:latest
Create docker-compose.yaml:
services:
api:
image: senaddizdarevic/docker-compose-api:latest
container_name: docker_compose_api
ports:
- "8080:80"
env_file:
- .env
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./test:/app/source/ #Add your docker-compose.yml source directory here.
Create .env file for storing variables.
MY_JWT_SECRET_KEY=your_default_jwt_secret_key # Create JWT secret key woth SSL command (openssl rand -hex 32)
API_USERNAME=admin
API_PASSWORD=password
Run the Docker container in detached mode:
docker compose up -d
The application provides the following endpoints:
/login: Authenticate with a username and password (admin/password)./runcmd: Run a docker-compose command. The command must start with docker-compose.# Obtain JWT token
TOKEN=$(curl -X POST http://localhost:8080/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "password"}' | jq -r .access_token)
# Run a docker-compose command
curl -X POST http://localhost:8080/runcmd \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"command":"docker-compose -f source/docker-compose.yml up -d"}'
Logging: Logs can be accessed through Docker logs for debugging and monitoring.
Gunicorn log
docker logs docker_compose_api
Flask log
docker exec -it docker_compose_api cat /app/api.log
Nginx logs
docker exec -it docker_compose_api cat /var/log/nginx/access.log
docker exec -it docker_compose_api cat /var/log/nginx/error.log
For more details, please refer to the official DockerComposeAPI documentation.
Content type
Image
Digest
sha256:d4f13ff70…
Size
152.9 MB
Last updated
about 2 years ago
docker pull senaddizdarevic/docker-compose-api