docker.recipes

Cockpit CMS

beginner

Self-hosted headless CMS with a simple API.

Overview

Cockpit is a self-hosted headless Content Management System developed by Agentejo that focuses on simplicity and API-first architecture. Unlike traditional CMS platforms, Cockpit separates content management from presentation, storing content in flexible Collections and Singletons while providing a clean REST API for frontend consumption. It emerged as a lightweight alternative to complex enterprise CMS solutions, offering developers the freedom to build custom frontends while content creators work within an intuitive admin interface. This stack combines Cockpit with MongoDB as the primary database engine, leveraging MongoDB's document-based storage model that naturally aligns with Cockpit's JSON-centric content structure. MongoDB's flexible schema design allows Cockpit to store diverse content types without rigid table structures, while its aggregation framework enables complex content queries through Cockpit's API layer. The document database approach eliminates the object-relational mapping overhead common in traditional SQL-based CMS systems. This combination serves developers building modern web applications, mobile apps, or multi-channel content distribution systems who need editorial workflows without frontend constraints. Startups and agencies benefit from rapid prototyping capabilities, while the headless architecture supports progressive web apps, static site generators, and custom React or Vue.js applications that require dynamic content management.

Key Features

  • JSON-based Collections system for structured content with custom field types and validation rules
  • Singletons for global configuration data like site settings, SEO metadata, and application constants
  • MongoDB aggregation pipeline integration for complex content queries and analytics
  • Token-based REST API authentication with granular permission controls per collection
  • Asset management with automatic image resizing and WebP conversion capabilities
  • Real-time content preview with webhook support for triggering builds in static site generators
  • Custom field components including repeaters, galleries, and markdown editors with live preview
  • MongoDB Change Streams integration for real-time content synchronization across multiple frontends

Common Use Cases

  • 1Headless blog or magazine platform feeding content to React, Vue.js, or Next.js frontends
  • 2Mobile app content management where iOS and Android apps consume the same content API
  • 3Multi-site content distribution serving different brands or regions from centralized content
  • 4E-commerce product catalog management for custom shopping experiences built with modern frameworks
  • 5Documentation systems where technical writers manage content consumed by developer portals
  • 6Digital agency client projects requiring custom designs without CMS theme limitations
  • 7Static site generator content source for Gatsby, Nuxt, or Eleventy build processes

Prerequisites

  • Minimum 1GB RAM for combined Cockpit and MongoDB operations with small datasets
  • Port 8080 available for Cockpit admin interface and API endpoints
  • Understanding of REST API concepts for frontend integration and token management
  • Basic JSON knowledge for content structure design and API response handling
  • MongoDB query familiarity for advanced content filtering and aggregation operations
  • Frontend development skills in JavaScript frameworks for headless implementation

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 cockpit:
3 image: agentejo/cockpit:latest
4 container_name: cockpit
5 restart: unless-stopped
6 volumes:
7 - cockpit_data:/var/www/html/storage
8 ports:
9 - "8080:80"
10 networks:
11 - cockpit-network
12
13 mongodb:
14 image: mongo:7
15 container_name: cockpit-mongodb
16 volumes:
17 - mongodb_data:/data/db
18 networks:
19 - cockpit-network
20
21volumes:
22 cockpit_data:
23 mongodb_data:
24
25networks:
26 cockpit-network:
27 driver: bridge

.env Template

.env
1# Default credentials: admin / admin

Usage Notes

  1. 1Docs: https://getcockpit.com/documentation
  2. 2Access at http://localhost:8080 - default login: admin / admin
  3. 3Change default password immediately after first login
  4. 4Create Collections for structured content, Singletons for config
  5. 5REST API: /api/collections/get/[name]?token=YOUR_TOKEN
  6. 6Lightweight alternative to larger headless CMS options

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

cockpit
cockpit:
  image: agentejo/cockpit:latest
  container_name: cockpit
  restart: unless-stopped
  volumes:
    - cockpit_data:/var/www/html/storage
  ports:
    - "8080:80"
  networks:
    - cockpit-network
mongodb
mongodb:
  image: mongo:7
  container_name: cockpit-mongodb
  volumes:
    - mongodb_data:/data/db
  networks:
    - cockpit-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 cockpit:
5 image: agentejo/cockpit:latest
6 container_name: cockpit
7 restart: unless-stopped
8 volumes:
9 - cockpit_data:/var/www/html/storage
10 ports:
11 - "8080:80"
12 networks:
13 - cockpit-network
14
15 mongodb:
16 image: mongo:7
17 container_name: cockpit-mongodb
18 volumes:
19 - mongodb_data:/data/db
20 networks:
21 - cockpit-network
22
23volumes:
24 cockpit_data:
25 mongodb_data:
26
27networks:
28 cockpit-network:
29 driver: bridge
30EOF
31
32# 2. Create the .env file
33cat > .env << 'EOF'
34# Default credentials: admin / admin
35EOF
36
37# 3. Start the services
38docker compose up -d
39
40# 4. View logs
41docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/cockpit-cms/run | bash

Troubleshooting

  • Admin interface shows 'Database connection failed': Verify MongoDB container is running and cockpit-network connectivity exists
  • API returns empty collections after content creation: Check MongoDB data persistence and ensure mongodb_data volume is properly mounted
  • Image uploads fail with permission errors: Verify cockpit_data volume permissions allow write access to /var/www/html/storage
  • Token authentication returns 401 errors: Generate new API tokens from Cockpit settings and verify token format in request headers
  • MongoDB container exits with 'insufficient memory': Increase Docker memory limits or reduce MongoDB cache size configuration
  • Collections return stale data after updates: Clear Cockpit cache from admin panel or restart cockpit container to refresh MongoDB connections

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