# Build the image to be used for this run. cd $OS && IMAGE=$(sudo docker build . | tail -1 | awk '{ print $NF }') # Build the directory to be mounted into Docker. MNT="$WORKSPACE/.." # Execute the build inside Docker. CONTAINER=$(sudo docker run -d -v "$MNT:/opt/project" $IMAGE /bin/bash -c "cd /opt/project/$OS && rake spec") # Attach to the container's streams so that we can see the output. sudo docker attach $CONTAINER # As soon as the process exits, get its return value. RC=$(sudo docker wait $CONTAINER) # Delete the container we've just used to free disk space. sudo docker rm $CONTAINER # Exit with the same value that the process exited with. exit $RC