Skip to content

Commit

Permalink
Gets actual exit status from Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Feb 11, 2015
1 parent c9ed01b commit bc28069
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Bugfixes:
* Pressing Ctrl+C wouldn't stop package identification with KeyboardInterrupt
* Fixes an error message while destroying a docker experiment
* Fixes docker not installing packages if they were packed
* Fixes docker always reporting exit status 0

Features:
* Adds `--install-pkgs` options to `docker setup`, to prefer installing
Expand Down
13 changes: 13 additions & 0 deletions reprounzip-docker/reprounzip/unpackers/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import argparse
from itertools import chain
import json
import logging
import os
import pickle
Expand Down Expand Up @@ -341,6 +342,18 @@ def docker_run(args):
'-h', hostname,
'-i', '-t', image,
'/bin/busybox', 'sh', '-c', cmds])
if retcode != 0:
logging.critical("docker run failed with code %d", retcode)
sys.exit(1)

# Get exit status from "docker inspect"
out = subprocess.check_output(['docker', 'inspect', container])
outjson = json.loads(out)
if (outjson[0]["State"]["Running"] is not False or
outjson[0]["State"]["Paused"] is not False):
logging.error("Invalid container state after execution:\n%s",
json.dumps(outjson[0]["State"]))
retcode = outjson[0]["State"]["ExitCode"]
sys.stderr.write("\n*** Command finished, status: %d\n" % retcode)

# Store container name (so we can download output files)
Expand Down

0 comments on commit bc28069

Please sign in to comment.