﻿RunWisp can run the services in an existing compose file. Each compose service
becomes a RunWisp service with run history, logs, restarts, and notifications.
The containers still run under Docker, and RunWisp never edits the compose file.

To keep running the stack with `docker compose up` and only schedule jobs in
it, you don't need this page: see [Docker tasks](/recipes/docker/).

## Point RunWisp at the compose file

Run `runwisp` in the directory with your `docker-compose.yml`. It detects the
file and first offers a starter that only schedules jobs in the stack. Decline
it, and accept the next offer to create a `runwisp.toml` that imports the
services:

```toml title="runwisp.toml"
[compose.myapp]
file = "./docker-compose.yml"
```

The alias (`myapp`) comes from the directory name. Open the Web UI at
`http://localhost:9477`; each compose service is listed as a RunWisp service.

You can also write this block yourself and start the daemon with
`runwisp daemon`. RunWisp calls the `docker compose` CLI, so Docker and the
Compose plugin must be installed.

## Stop the compose stack

RunWisp starts its own containers with `docker compose run`. If the stack is
already running from `docker compose up`, RunWisp attaches to each running
service container instead of starting a second one, and takes it over at the
next restart. Stopping the daemon stops those containers too. See
[`import = "services"`](/configuration/compose/#import--services-default).

For a clean start under RunWisp, stop the stack first:

```bash
docker compose down
```

## How the pieces map

| docker-compose                   | RunWisp                                                                                                  |
| -------------------------------- | -------------------------------------------------------------------------------------------------------- |
| a service                        | a RunWisp service named `myapp.<service>` ([`name_format`](/configuration/compose/#name_format))         |
| `restart:`                       | ignored; RunWisp restarts on failure by default ([`restart`](/configuration/compose/#imported-defaults)) |
| `stop_grace_period`              | [`graceful_stop`](/configuration/tasks/#graceful_stop)                                                   |
| `profiles`                       | [`profiles`](/configuration/compose/#profiles)                                                           |
| images, networks, volumes, ports | used as they are                                                                                         |
| `depends_on`                     | not started for you; import those services too, or set [`with_deps`](/configuration/compose/#with_deps)  |

## Common changes

Per-service settings go in a sub-table named after the compose service.

Restart after every exit, not only failures:

```toml title="runwisp.toml"
[compose.myapp.api]
restart = "always"
```

Get notified on failure (see [Notifications](/notifications/)):

```toml title="runwisp.toml"
[compose.myapp.api]
notify = ["slack-prod"]
```

Run four copies of a worker. Each gets `RUNWISP_INSTANCE_INDEX` (0 to 3):

```toml title="runwisp.toml"
[compose.myapp.worker]
instances = 4
```

Import only some services, or leave some out:

```toml title="runwisp.toml"
[compose.myapp]
services = ["api", "worker"]   # only these
# services = ["-db"]           # everything except db
```

Run a compose service on a schedule, in a fresh container each time:

```toml title="runwisp.toml"
[tasks.nightly-backup]
cron            = "0 3 * * *"
compose_file    = "./docker-compose.yml"
compose_service = "backup"
```

## What needs a human

- **`restart:` policies.** RunWisp ignores them. Set
  [`restart`](/configuration/services/#restart) per service if the default
  (restart on failure) isn't what you want.
- **Docker access.** The user running RunWisp needs access to the Docker
  daemon. If RunWisp runs in a container, see
  [Docker tasks](/recipes/docker/#if-runwisp-runs-in-a-container).

## Learn more

- [`[compose.*]`](/configuration/compose/): import strategies, per-service
  settings, naming
- [Docker tasks](/recipes/docker/)
