代码拉取完成,页面将自动刷新
#!/bin/sh
container=simpleitk-notebooks
image=insighttoolkit/simpleitk-notebooks
port=8888
extra_run_args=""
quiet=""
show_help() {
cat << EOF
Usage: ${0##*/} [-h] [-q] [-c CONTAINER] [-i IMAGE] [-p PORT] [-r DOCKER_RUN_FLAGS]
This script is a convenience script to run Docker images. It:
- Makes sure docker is available
- On Windows and Mac OSX, creates a docker machine if required
- Informs the user of the URL to access the container with a web browser
- Stops and removes containers from previous runs to avoid conflicts
- Mounts the present working directory to /home/jovyan/notebooks on Linux and Mac OSX
- Prints out the graphical app output log following execution
Options:
-h Display this help and exit.
-c Container name to use (default ${container}).
-i Image name (default ${image}).
-p Port to expose the notebook server (default ${port}). If an empty
string, the port is not exposed.
-r Extra arguments to pass to 'docker run'.
-q Do not output informational messages.
EOF
}
while [ $# -gt 0 ]; do
case "$1" in
-h)
show_help
exit 0
;;
-c)
container=$2
shift
;;
-i)
image=$2
shift
;;
-p)
port=$2
shift
;;
-r)
extra_run_args="$extra_run_args $2"
shift
;;
-q)
quiet=1
;;
*)
show_help >&2
exit 1
;;
esac
shift
done
which docker 2>&1 >/dev/null
if [ $? -ne 0 ]; then
echo "Error: the 'docker' command was not found. Please install docker."
exit 1
fi
os=$(uname)
if [ "${os}" != "Linux" ]; then
vm=$(docker-machine active 2> /dev/null || echo "default")
if ! docker-machine inspect "${vm}" &> /dev/null; then
if [ -z "$quiet" ]; then
echo "Creating machine ${vm}..."
fi
docker-machine -D create -d virtualbox --virtualbox-memory 2048 ${vm}
fi
docker-machine start ${vm} > /dev/null
eval $(docker-machine env $vm --shell=sh)
fi
ip=$(docker-machine ip ${vm} 2> /dev/null || echo "localhost")
url="http://${ip}:$port"
cleanup() {
docker stop $container >/dev/null
docker rm $container >/dev/null
}
running=$(docker ps -a -q --filter "name=${container}")
if [ -n "$running" ]; then
if [ -z "$quiet" ]; then
echo "Stopping and removing the previous session..."
echo ""
fi
cleanup
fi
if [ -z "$quiet" ]; then
echo ""
echo "Setting up the notebook container..."
echo ""
if [ -n "$port" ]; then
echo "Point your web browser to ${url}"
echo ""
fi
fi
pwd_dir="$(pwd)"
mount_local=""
if [ "${os}" = "Linux" ] || [ "${os}" = "Darwin" ]; then
mount_local=" -v ${pwd_dir}:/home/jovyan/notebooks "
fi
port_arg=""
if [ -n "$port" ]; then
port_arg="-p $port:8888"
fi
docker run \
-d \
--name $container \
${mount_local} \
$port_arg \
$extra_run_args \
$image >/dev/null
trap "docker stop $container >/dev/null" SIGINT SIGTERM
docker wait $container >/dev/null
# vim: noexpandtab shiftwidth=4 tabstop=4 softtabstop=0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。