Hi!
When using lifecycle hooks, how can we get the commands status, exit code and output?
I tried looking at the container logs, inspecting the container but couldn’t find anything
thank you,
Share and learn in the Docker community.
Hi!
When using lifecycle hooks, how can we get the commands status, exit code and output?
I tried looking at the container logs, inspecting the container but couldn’t find anything
thank you,
I don’t see any way for it in the documentation, but after trying it and checking the source code, it should actually give you the exit code if there is any non-zero exist code. I don’t see any way to get it in a machine readable way, but you can see it in the terminal
services:
app:
image: nginx
post_start:
- command:
- sh
- -c
- exit 5
output
[+] Running 1/2
✔ Network hook_default Created 0.1s
⠸ Container hook-app-1 Starting 0.3s
app hook exited with status
It is written to the standard error as the rest of the status text.
Just in case you are interested in the source code
The output could be redirected to a file so you can read it from the container. But that has to be implemented i your hook script.