代码拉取完成,页面将自动刷新
#!/bin/bash
force_stop() {
docker stop $1 &> /dev/null
docker rm $1 &> /dev/null
}
inspect() {
if hash docker-machine 2>/dev/null; then
docker-machine ssh $DOCKER_MACHINE_NAME docker inspect --format=$2 $1
elif hash boot2docker 2>/dev/null; then
boot2docker ssh docker inspect --format=$2 $1
else
docker inspect --format=$2 $1
fi
}
get_ip() {
if hash docker-machine 2>/dev/null; then
docker-machine ip $DOCKER_MACHINE_NAME 2>/dev/null
elif hash boot2docker 2>/dev/null; then
boot2docker ip 2>/dev/null
else
# The following gives the ip address of the container. We
# don't need this information though. On Linux systems the
# systems can be accessed via 127.0.0.1
# docker inspect --format={{.NetworkSettings.IPAddress}} $1
echo "127.0.0.1"
fi
}
run() {
docker run "$@"
local status=$?
if [ $status -ne 0 ]; then
echo >&2
echo "Failed to start the Docker container." >&2
exit 1
fi
local container_id="$(docker ps -n=1 | tail -n 1 | awk '{print $1}')"
local container_name=$(inspect $container_id '{{.Name}}')
# strip the leading / character
container_name=${container_name#?}
local container_ip=$(get_ip $container_id)
local host_ports=$(inspect $container_id '' | \
grep HostPort | \
sed 's/[^0-9]*//g' | \
sort -nu)
echo "Container started"
echo "Name: $container_name"
echo "IP: $container_ip"
echo "Ports: $(echo $host_ports | tr '\\n' ',')"
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。