fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.88k stars 642 forks source link

postStart exec breakOnError only fails when all containers have started #970

Open jpraet opened 6 years ago

jpraet commented 6 years ago

I have a build with multiple docker images, and have configured startParallel = false, so the containers start sequentially.

The first container (db2express) is configured with a postExec wait action, with breakOnError=true.

I notice because of delay in the logs that the postExec script of the first container is executed before the second container is started. This is as expected. However, when the postExec script fails, I would expect the build to fail immediately. Instead, it first starts the remaining containers, and only once they are all started am I seeing the error from the postExec script.

This is docker-maven-plugin 0.24.0 and docker 0.12.6 on Windows 7.

[INFO] DOCKER> [docker-stable.cbss.inet/cbsstools/db2express-c:latest] "db2express-openshift-poc-1.12": Start container d2e3dc52c8e2
[INFO] DOCKER> [rodolpheche/wiremock:2.1.11] "wiremock-openshift-poc-1.12": Start container 7b420510f7eb
[INFO] DOCKER> Pattern 'port' matched for container 7b420510f7eb
[INFO] DOCKER> [rodolpheche/wiremock:2.1.11] "wiremock-openshift-poc-1.12": Waited on log out 'port' 1708 ms
[INFO] DOCKER> [selenium/standalone-chrome:3.8.1] "selenium-openshift-poc-1.12": Start container 71c42c7d2368
[INFO] DOCKER> Pattern 'Selenium Server is up and running' matched for container 71c42c7d2368
[INFO] DOCKER> [selenium/standalone-chrome:3.8.1] "selenium-openshift-poc-1.12": Waited on log out 'Selenium Server is up and running' 3883 ms
[INFO] DOCKER> [docker-snapshots.cbss.inet/openshift-poc:1.12-dev-SNAPSHOT] "jboss-openshift-poc-1.12": Start container da71fdb63e18
[ERROR] DOCKER> Error occurred during container startup, shutting down...
[INFO] DOCKER> [docker-snapshots.cbss.inet/openshift-poc:1.12-dev-SNAPSHOT] "jboss-openshift-poc-1.12": Stop and removed container da71fdb63e18 after 0 ms
[INFO] DOCKER> [selenium/standalone-chrome:3.8.1] "selenium-openshift-poc-1.12": Stop and removed container 71c42c7d2368 after 0 ms
[INFO] DOCKER> [rodolpheche/wiremock:2.1.11] "wiremock-openshift-poc-1.12": Stop and removed container 7b420510f7eb after 0 ms
[INFO] DOCKER> [docker-stable.cbss.inet/cbsstools/db2express-c:latest] "db2express-openshift-poc-1.12": Stop and removed container d2e3dc52c8e2 after 0 ms
[ERROR] DOCKER> Executing '/bin/bash' with args '[-c, /init-database.sh]' inside container 'db2express-openshift-poc-1.12' [docker-stable.cbss.inet/cbsstools/db2express-c](d2e3dc52c8e2) resulted in a non-zero exit code: 4
rhuss commented 6 years ago

I agree with you that the plugin should 'fail fast'. Shouldn't be hard to fix hopefully. I hope to jump on to this asap, but you could accelerate this by submitting a PR ;-)