You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`post_start`defines a sequence of lifecycle hooks to run after a container has started. The exact timing of when the command is run is not guaranteed.
1513
+
1514
+
- `command`: Specifies the command to run once the container starts. This attribute is required, and you can choose to use either the shell form or the exec form.
1515
+
- `user`: The user to run the command. If not set, the command is run with the same user as the main service command.
1516
+
- `privileged`: Lets the `post_start` command run with privileged access.
1517
+
- `working_dir`: The working directory in which to run the command. If not set, it is run in the same working directory as the main service command.
1518
+
- `environment`: Sets environment variables specifically for the `post_start` command. While the command inherits the environment variables defined for the service’s main command, this section lets you add new variables or override existing ones.
1519
+
1520
+
```yaml
1521
+
services:
1522
+
test:
1523
+
post_start:
1524
+
- command: ./do_something_on_startup.sh
1525
+
user: root
1526
+
privileged: true
1527
+
environment:
1528
+
- FOO=BAR
1529
+
```
1530
+
1531
+
For more information, see [Use lifecycle hooks](/manuals/compose/how-tos/lifecycle.md).
`pre_stop`defines a sequence of lifecycle hooks to run before the container is stopped. These hooks won't run if the container stops by itself or is terminated suddenly.
1538
+
1539
+
Configuration is equivalent to [`post_start](#post_start).
1540
+
1508
1541
### privileged
1509
1542
1510
1543
`privileged`configures the service container to run with elevated privileges. Support and actual impacts are platform specific.
0 commit comments