-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'fig up' should return with non-zero exit-code if some container "failed" #683
Comments
To make it reproducible: docker run -it --rm busybox "false"
echo $? gives With this fig.yml: # fig.yml
foo:
image: busybox
command: "false" I can do fig up
echo $? gives 0, even though fig outputs something like |
+1 |
1 similar comment
+1 |
I think this is expected behaviour. But If you need this behaviour you should be able to use |
@dnephin I agree that, since Since we do not know, which container failed, it does not make sense to return the exact error-code of the failed container. I could imagine to have different error-codes of But if the user needs to fiddle with My specific use case is this: I run functional tests with |
@matleh that makes a lot of sense. I use fig for the exactly same thing! Sometimes I have tests run on the hosts, and sometimes it's from a testrunner container. I've used Is there a reason that Edit: If it's an issue with not all containers being linked up, I believe this should work:
|
I like to see the colored output from all the containers - helps me to understand what is going on. And |
@dnephin I just now read your edit: wouldn't that run testrunner twice - once as part of Besides that, it feels more like a work-around to use both But I have that feeling, that I might miss something important about |
@matleh yes, that's true, it does run twice. I set the command in the container to be something like fig pull
fig build
fig up -d
fig run tester /code/test.sh
fig stop
fig rm --force <any data volume containers> If you're concerned about the tester running twice, you could also change the I think in general if you need a response code, or you want to run something automated, |
@dnephin thank you for the insight into your way of doing things. I am sure that this works great. But I still think, that it is viable to do things in different ways as different people and different scenarios have different priorities, expectations and so on. So where All I ask for, is for To me |
I think that fig must return more meaningful exit-codes
In this workflow all look good, but if my heedless user accidentally run this steps:
Can I check is containers are running? I can get I thing that situation with workflow is wrong because |
I've found the workaround of how to catch the exit code in fig. This is not very clean and nice solution, but at least it works for me.
|
OR total tally exit code for any service starting with test
|
+1 |
Just got tripped up by this as well. Using |
Why not use |
@ebuchman I am in the exact same situation. I will try your workaround. But this definitely needs to be handled properly in compose @dnephin that is another way to do it, but I feel it is just another workaround for what should work as expected. I use separate test containers that have all my test framework dependancies so I can just run them 'attached' them to my app containers and get test results. Using |
@dnephin it seems your suggestion doesn't work? Am I doing something wrong? docker-compose.yml:
|
I'm not really convinced of that. I would much rather see On the other hand,
I don't understand what you're trying to do here. Could you link to a sample config? (edit: I see the config now, will look) I can say that my primary (and almost exclusive) use-case for docker-compose is CI, and I have never encountered any issue with this.
|
That should be This works: docker-compose.yml tester:
image: busybox
command: sleep 100 $ docker-compose run tester cat /file/does/not/exist
cat: can't open '/file/does/not/exist': No such file or directory
$ echo $?
1 |
Yep, that works. Not sure where I got Your workaround is actually fine for me. I understand the complications of handling exited codes from processes in a container that don't relate to Either way I am fine with just using |
copy paste example of using
Returns how many non-0 exit codes were returned. Would be 0 if everything exited with code 0. |
Using the |
Fixed in #4397 |
fig run <container>
does already return the exit-code of the container (see #197) butfig up
returns with 0 no matter what the exit-code of the started containers is.It would be helpful to able to detect, if one of the containers returned with a non-zero exit code and have fig return a non-zero exit-code in that case, too.
Also,
fig up
does end with exit-code 1 if one of the containers could not be started at all, and also if one does Ctl-C once, but it ends with exit-code 0 of one does Ctl-C twice. It would be more in line with "standard unix behavior" if fig would exit with -2 in case of single Ctl-C (SIGINT) and -9 in case of double Ctl-C (SIGKILL).The text was updated successfully, but these errors were encountered: