agentleFS
ivangrynenkoivangrynenko/cursorrules/.cursor/rules/docker-compose-standards.mdc

cursorrules / rules

Cursor rule88 starsChanged 13 months agoMITView on GitHub

Docker Compose standards Rule

The file

We split this docker-compose-standards.mdc into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use consistent indentation: Use 2 spaces for indentation.

    line 52
  2. Distinctive:

    Avoid 'links' key: Use networks and service names for service communication.

    line 59
  3. Distinctive:

    Avoid privileged mode: Do not use 'privileged: true'.

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
docker-compose-standards.mdc
---
description: Docker Compose standards Rule
globs: 
alwaysApply: false
---

## Rule Details

- **Name:** docker_compose_best_practices

- **Description:** Enforces best practices in docker-compose files to ensure maintainability, security, and consistency

## Filters
- file name: `docker-compose\\.ya?ml$`
- event: `(file_create|file_modify)`

## Rejections
- Conditions:
  - pattern `^\\s*version\\s*:` – The 'version' field is deprecated in Docker Compose files. Compose files are now version-less by default.

## Rejections
- Conditions:
  - pattern `^(  |\t)` – Inconsistent indentation detected. Use 2 spaces for indentation.

## Rejections
- Conditions:
  - pattern `^\\s*links\\s*:` – The 'links' key is deprecated. Use networks and service names for inter-service communication.

## Rejections
- Conditions:
  - pattern `^\\s*image\\s*:\\s*[^:]+$` – Specify an explicit image tag to ensure consistency.

## Rejections
- Conditions:
  - pattern `^\\s*privileged\\s*:\\s*true` – Running services in privileged mode is discouraged for security reasons.

## Rejections
- Conditions:
  - pattern `^\\s*services\\s*:\\s*[^\\n]+\\n(?!.*\\blimits\\b)` – Define resource limits for each service to prevent resource exhaustion.

## Suggestions
- Guidance:
To adhere to Docker Compose best practices:

1. **Omit the 'version' field**: Compose files are version-less by default.
   ```yaml
   services:
     web:
       image: nginx
   ```

2. **Use consistent indentation**: Use 2 spaces for indentation.
   ```yaml
   services:
     web:
       image: nginx
   ```

3. **Avoid 'links' key**: Use networks and service names for service communication.
   ```yaml
   services:
     web:
       image: nginx
       networks:
         - my-network
     db:
       image: mysql
       networks:
         - my-network
   networks:
     my-network:
   ```

4. **Specify explicit image tags**: Prevent unintended updates by defining image tags.
   ```yaml
   services:
     web:
       image: nginx:1.21.0
   ```

5. **Avoid privileged mode**: Do not use 'privileged: true'. Grant specific capabilities if necessary.
   ```yaml
   services:
     web:
       image: nginx
       cap_add:
         - NET_ADMIN
   ```

6. **Define resource limits**: Prevent services from consuming excessive resources.
   ```yaml
   services:
     web:
       image: nginx
       deploy:
         resources:
           limits:
             cpus: '0.50'
             memory: '512M'
   ```

Implementing these practices ensures secure, maintainable, and consistent Docker Compose configurations.

## Metadata
- Priority: high
- Version: 1.1

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.