echo " stop: Stop a running container"
echo " restart: Restart a container"
echo " destroy: Stop and remove a container"
- echo " enter: Use nsenter to get a shell into a container"a
+ echo " enter: Use nsenter to get a shell into a container"
echo " logs: View the Docker logs for a container"
echo " bootstrap: Bootstrap a container for the config based on a template"
echo " rebuild: Rebuild a container (destroy old, bootstrap, start new)"
while [ ${#} -gt 0 ]; do
case "${1}" in
-
+ --debug)
+ DEBUG="1"
+ ;;
--skip-prereqs)
- SKIP_PREREQ="1"
+ SKIP_PREREQS="1"
;;
--docker-args)
user_args="$2"
cd "$(dirname "$0")"
-docker_min_version='1.6.0'
-docker_rec_version='1.6.0'
+docker_min_version='1.8.0'
+docker_rec_version='1.8.0'
git_min_version='1.8.0'
git_rec_version='1.8.0'
config_file=containers/"$config".yml
cidbootstrap=cids/"$config"_bootstrap.cid
local_discourse=local_discourse
-image=discourse/discourse:1.0.17
+image=discourse/discourse:1.3.2
docker_path=`which docker.io || which docker`
git_path=`which git`
# docker added more hostname rules
hostname=${hostname//_/-}
+ mac_address="--mac-address $($docker_path run $user_args -i --rm -a stdout -a stderr $image /bin/sh -c "echo $hostname | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'")"
+
set -x
$docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname" \
- -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $docker_args $run_image $boot_command
+ -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $mac_address $docker_args \
+ $run_image $boot_command
)
exit 0
echo $run_command
+ unset FAILED
(exec echo "$input" | $docker_path run $user_args $links "${env[@]}" -e DOCKER_HOST_IP=$docker_ip --cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image \
- /bin/bash -c "$run_command") \
- || ($docker_path rm `cat $cidbootstrap` && rm $cidbootstrap)
+ /bin/bash -c "$run_command") || FAILED="TRUE"
- [ ! -e $cidbootstrap ] && echo "** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one" && exit 1
+ if [[ $FAILED = "TRUE" ]]; then
+ if [[ ! -z "$DEBUG" ]]; then
+ $docker_path commit `cat $cidbootstrap` $local_discourse/$config-debug || echo 'FAILED TO COMMIT'
+ echo "** DEBUG ** Maintaining image for diagnostics $local_discourse/$config-debug"
+ fi
+
+ $docker_path rm `cat $cidbootstrap`
+ rm $cidbootstrap
+ echo "** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one"
+ exit 1
+ fi
sleep 5