Skip to content

Commit a192630

Browse files
committed
ENGDOCS-2282
1 parent 8dd2476 commit a192630

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

content/reference/compose-file/services.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,35 @@ ports:
15051505
mode: host
15061506
```
15071507

1508+
## post_start
1509+
1510+
`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.
1511+
1512+
- `command`: The command to run after the container has started. This attribute is required.
1513+
- `user`: The user to run the command. If not set, the command is run with the same user as the main service command.
1514+
- `privileged`: Lets the `post_start` command run with privileged access.
1515+
- `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.
1516+
- `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.
1517+
1518+
```yaml
1519+
services:
1520+
test:
1521+
post_start:
1522+
- command: ./do_something_on_startup.sh
1523+
user: root
1524+
privileged: true
1525+
environment:
1526+
- FOO=BAR
1527+
```
1528+
1529+
For more information, see [Use lifecycle hooks](/manuals/compose/how-tos/lifecycle.md).
1530+
1531+
## pre_stop
1532+
1533+
`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.
1534+
1535+
Configuration is equivalent to [`post_start](#post_start).
1536+
15081537
### privileged
15091538

15101539
`privileged` configures the service container to run with elevated privileges. Support and actual impacts are platform specific.

0 commit comments

Comments
 (0)