moby: Docker commands should return nonzero error codes on failure

It would be good to do an audit of each command and ensure that all failure modes result in a nonzero exit status code.

I just noticed that a failed pull has a 0 exit status.

$ docker pull foo/bar
Pulling repository foo/bar
Error: HTTP code: 404
$ echo $?
0

This is important when you’re trying to use docker programmatically. It’s not great to have to search for error messages in the output.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Reactions: 6
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@tianon Thanks! I had just installed the latest yesterday. The 0.8.0 version seems to fix it. That’s much easier than wrapping in a bash script like this:

docker run --name $name <id> &> /dev/null
ret=$(docker inspect -format='{{.State.ExitCode}}' $name)
docker rm $name
exit $ret