Created
May 1, 2022 03:22
-
-
Save sgpinkus/45f6c2728bcfb36bda29b83910fac769 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=service that simply pipes certain docker events to logs | |
[Service] | |
ExecStart=/usr/local/bin/docker-events-to-logs.sh | |
Restart=on-failure | |
ExecReload=/bin/kill -s HUP $MAINPID | |
ExecStop=/bin/kill -s TERM $MAINPID | |
PrivateTmp=true | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# docker events --filter="type=container" --filter="type=service" --filter="type=node" --format '{{json .}}' | jq '.' | |
docker events \ | |
--filter 'type=container' \ | |
--filter 'type=service' \ | |
--format 'type={{.Type}} action="{{.Action}}" scope={{.Scope}} exit_code="{{.Actor.Attributes.exitCode}}" container_name={{.Actor.Attributes.name}} image={{.Actor.Attributes.image}} swarm_stack="{{index .Actor.Attributes "com.docker.stack.namespace"}}" swarm_service="{{index .Actor.Attributes "com.docker.stack.namespace"}}"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment