-
-
Notifications
You must be signed in to change notification settings - Fork 1
Auto Restarting Containers
Real Compose restarts a container tagged restart: always when it exits. wslc has no such
policy, and no push-based "container exited" notification for wip to hook into — so the closest
approximation is polling: wip up --watch.
Reference for the values and their limits: Restart Policies.
Tag the containers you want supervised:
# wip.yml — mode: container
container: app
network: app-tier
dependencies:
app:
image: myapp:dev
restart: unless-stopped
ports:
- "3000:3000"
worker:
image: myapp:dev
command: bundle exec sidekiq
restart: on-failure:5
postgres:
image: postgres:16
restart: always
env:
POSTGRES_PASSWORD: password
mailcatcher:
image: sj26/mailcatcher
# no restart: → never auto-restartedOr in compose.yml under compose-native mode:
services:
worker:
image: myapp:dev
command: bundle exec sidekiq
restart: unless-stopped$ wip up --watch
wip: creating network 'app-tier'
wip: dependency 'postgres' not found, creating it
wip: dependency 'worker' not found, creating it
wip: container 'app' not found, creating it
wip: watching app, worker, postgres, mailcatcher for exited restart: containers every 5s (running detached; Ctrl-C to stop)Every 5 seconds it checks each dependency's state and restarts the exited ones whose restart:
allows it:
wip: 'worker' has exited, restarting it (restart: on-failure:5)--interval N changes the period:
wip up --watch --interval 10The primary container can't hold an attached TTY while the loop polls on the same thread, so it
always runs detached under --watch. To see its output:
# terminal 2 — compose modes only
wip logs -f
# or, any mode
wslc logs -f appAll three restarting values behave identically: an exited container is restarted regardless of exit
status. Real on-failure skips a clean (zero) exit; this loop doesn't, because reading the code
would need a heavier call per tick. on-failure:5's retry count is likewise not enforced.
If your worker exits 0 on purpose when it's done, --watch will restart it forever. Use
restart: no (or omit it) for anything that's meant to finish.
The loop asks "is this container exited right now?", not "did it just exit?" It cannot tell a crash
from a wip stop you ran in another terminal — so it may restart what you deliberately stopped.
Ctrl-C the watch loop first, then wip stop / wip down.
A removed container reports state deleted, not exited, and --watch only ever runs start.
Recovering from a wip down needs a fresh wip up.
`wip up --watch` is not supported under mode: compose (wip never parses a compose.yml
service list in that mode, so there is nothing to poll)
Use your compose tool's own restart handling. See Compose Mode.
Run the loop with --debug — wip logs the raw wslc list entry it read for each dependency:
$ wip up --watch --debug
wip: [debug] 'worker': {"Name"=>"worker", "State"=>3, …}Compare State against the enum: 0 invalid, 1 created, 2 running, 3 exited, 4 deleted.
Only 3 triggers a restart.
Checklist:
- Is
restart:an exact match foralways/unless-stopped/on-failure[:N]? Typos are silently inert. - Did you quote
restart: "no"when you meant something else? Unquotednois a YAML boolean. - Is the container actually
exited(3), ordeleted(4)? - Is the loop still running? It's a foreground process.
It's a development convenience for the case where a sidecar occasionally dies and you'd rather not notice. It is not a production supervisor: there's no daemon, no backoff, no exit-code awareness, and no logging beyond your terminal. For anything that must stay up unattended, use a real process supervisor on the host.
Introduction
Modes
Configuration
- Configuration Reference
- Config File Discovery
- Dependencies
- Networking
- Interactions
- Restart Policies
- Env Files
- Secret Masking
- Dockerignore
- Shadow Build Context
- Source Sync
- Sync Modes
compose.yml support
- Compose File Support
- Compose Build
- Compose Depends On
- Compose Profiles
- Compose Variable Interpolation
Commands
- CLI Command Reference
- wip init
- wip version
- wip doctor
- wip config
- wip build
- wip up
- wip stop
- wip down
- wip exec
- wip run
- wip shell
- wip logs
- wip sync
- wip dispatch
- Global Options
- Debug Output
- TTY Allocation
Guides
- Guides
- Migrating from dip
- Reusing an Existing compose.yml
- Fixing a Slow Boot
- Continuous Sync
- Auto Restarting Containers
- Multi Arch Images
- Using wip in CI
Troubleshooting
- Troubleshooting & FAQ
- FAQ
- Configuration Errors
- WSLC Not Found
- Registry Authentication
- Architecture Mismatch
- Volume Limit Reached
- rsync Not Found
- Reporting Issues
Comparison
Project