I use Gitlab CI/CD to deploy new images to staging server when I make a new commit. In my pipeline the essential part is
docker service update my_service --update-failure-action rollback --image my_image:latest
Sometime the deployment fails then the automatic rollback kicks in. However docker service update always returns 0, so in my pipeline I have no way to know whether the deployment was successful or not. 
How can I detect if deployment was really successful / if there was a rollback?
For get update status you can run:
docker service inspect my_service --format "{{.UpdateStatus.State}}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With