Home Explore Blog Models CI



docker

1st chunk of `content/reference/compose-file/develop.md`
ea3ae6e9873a795095fd0d8e2876116fc5230d2a640663b50000000100000b2b
---
title: Compose Develop Specification
description: Learn about the Compose Develop Specification
keywords: compose, compose specification, compose file reference, compose develop specification
aliases:
 - /compose/compose-file/develop/
weight: 150
---

> [!NOTE] 
>
> Develop is an optional part of the Compose Specification. It is available with Docker Compose version 2.22.0 and later.

{{% include "compose/develop.md" %}}

This page defines how Compose behaves to efficiently assist you and defines the development constraints and workflows set by Compose. Only a subset of Compose file services may require a `develop` subsection.

## Illustrative example

```yaml
services:
  frontend:
    image: example/webapp
    build: ./webapp
    develop:
      watch: 
        # sync static content
        - path: ./webapp/html
          action: sync
          target: /var/www
          ignore:
            - node_modules/

  backend:
    image: example/backend
    build: ./backend
    develop:
      watch: 
        # rebuild image and recreate service
        - path: ./backend/src
          action: rebuild
```

## Attributes

<!-- vale Docker.HeadingSentenceCase = NO ) -->

The `develop` subsection defines configuration options that are applied by Compose to assist you during development of a service with optimized workflows.

### `watch`

The `watch` attribute defines a list of rules that control automatic service updates based on local file changes. `watch` is a sequence, each individual item in the sequence defines a rule to be applied by 
Compose to monitor source code for changes. For more information, see [Use Compose Watch](/manuals/compose/how-tos/file-watch.md).

#### `action`

`action` defines the action to take when changes are detected. If `action` is set to:

- `rebuild`: Compose rebuilds the service image based on the `build` section and recreates the service with the updated image.
- `restart`: Compose restarts the service container. Available with Docker Compose version 2.32.0 and later.
- `sync`: Compose keeps the existing service container(s) running, but synchronizes source files with container content according to the `target` attribute.
- `sync+restart`: Compose synchronizes source files with container content according to the `target` attribute, and then restarts the container. Available with Docker Compose version 2.23.0 and later.
- `sync+exec`: Compose synchronizes source files with container content according to the `target` attribute, and then executes a command inside the container. Available with Docker Compose version 2.32.0 and later.

#### `exec`

{{< summary-bar feature_name="Compose exec" >}}

`exec` is only relevant when `action` is set to `sync+exec`. Like [service hooks](services.md#post_start), `exec` is used to define the command to be run inside the container once it has started.

Title: Compose Develop Specification
Summary
This document describes the Compose Develop Specification, which is an optional part of the Compose Specification available in Docker Compose version 2.22.0 and later. It defines how Compose assists developers during service development, focusing on optimized workflows and development constraints. The 'develop' section can be used to define watch rules for automatic service updates based on local file changes, specifying actions like 'rebuild', 'restart', 'sync', 'sync+restart', or 'sync+exec' when changes are detected. It includes information about the 'watch' attribute and its sub-attributes such as 'action' and 'exec'.