echo " run: Run the given command with the config in the context of the last bootstrapped image"
echo " rebuild: Rebuild a container (destroy old, bootstrap, start new)"
echo " cleanup: Remove all containers that have stopped for > 24 hours"
+ echo " start-cmd: Generate docker command used to start container"
echo
echo "Options:"
echo " --skip-prereqs Don't check launcher prerequisites"
config_file=containers/"$config".yml
cidbootstrap=cids/"$config"_bootstrap.cid
local_discourse=local_discourse
-image=discourse/base:2.0.20181031
-docker_path=`which docker.io || which docker`
+image="discourse/base:2.0.20190321-0122"
+docker_path=`which docker.io 2> /dev/null || which docker`
git_path=`which git`
if [ "${SUPERVISED}" = "true" ]; then
p e
end
end
- puts ports.map {|p| "-p\n#{p}"}.join("\n")
+ puts ports.map { |p| p.to_s.include?(':') ? "-p\n#{p}" : "--expose\n#{p}" }.join("\n")
RUBY
tmp_input_file=$(mktemp)
echo "YAML syntax error. Please check your containers/*.yml config files."
exit 1
fi
+
+ merge_user_args
}
if [ -z $docker_path ]; then
fi
}
+merge_user_args() {
+ local docker_args
+
+ docker_args=`cat $config_file | $docker_path run $user_args --rm -i -a stdout -a stdin $image ruby -e \
+ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['docker_args']"`
+
+ if [[ -n "$docker_args" ]]; then
+ user_args="$user_args $docker_args"
+ fi
+}
+
run_start() {
- existing=`$docker_path ps | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
- echo $existing
- if [ ! -z $existing ]
+ if [ -z "$START_CMD_ONLY" ]
then
- echo "Nothing to do, your container has already started!"
- exit 0
- fi
+ existing=`$docker_path ps | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
+ echo $existing
+ if [ ! -z $existing ]
+ then
+ echo "Nothing to do, your container has already started!"
+ exit 0
+ fi
- existing=`$docker_path ps -a | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
- if [ ! -z $existing ]
- then
- echo "starting up existing container"
- (
- set -x
- $docker_path start $config
- )
- exit 0
+ existing=`$docker_path ps -a | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
+ if [ ! -z $existing ]
+ then
+ echo "starting up existing container"
+ (
+ set -x
+ $docker_path start $config
+ )
+ exit 0
+ fi
fi
host_run
- docker_args=`cat $config_file | $docker_path run $user_args --rm -i -a stdout -a stdin $image ruby -e \
- "require 'yaml'; puts YAML.load(STDIN.readlines.join)['docker_args']"`
-
set_template_info
set_volumes
set_links
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/'")"
fi
+ if [ ! -z "$START_CMD_ONLY" ] ; then
+ docker_path="true"
+ fi
+
set -x
+
$docker_path run --shm-size=512m $links $attach_on_run $restart_policy "${env[@]}" "${labels[@]}" -h "$hostname" \
- -e DOCKER_HOST_IP="$docker_ip" --name $config -t "${ports[@]}" $volumes $mac_address $docker_args $user_args \
+ -e DOCKER_HOST_IP="$docker_ip" --name $config -t "${ports[@]}" $volumes $mac_address $user_args \
$run_image $boot_command
)
exit 0
;;
+ start-cmd)
+ START_CMD_ONLY="1"
+ run_start
+ exit 0;
+ ;;
+
start)
run_start
exit 0