添加一个nginx脚本,用于执行容器内的nginx命令
This commit is contained in:
parent
9f5db1fc42
commit
f2d14ffc29
20
nginx
Executable file
20
nginx
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 获取脚本所在目录的绝对路径
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
|
||||
# 切换工作目录到脚本所在目录
|
||||
cd "$SCRIPT_DIR" || exit 1
|
||||
|
||||
# 使用heredoc构建docker run命令
|
||||
read -r -d '' DOCKER_COMMAND <<'EOF'
|
||||
docker exec -it nginx nginx
|
||||
EOF
|
||||
|
||||
# 检查是否有传递参数,并将它们附加到命令的末尾
|
||||
if [ $# -gt 0 ]; then
|
||||
DOCKER_COMMAND+=" $@"
|
||||
fi
|
||||
|
||||
# 执行docker run命令
|
||||
eval "$DOCKER_COMMAND"
|
Loading…
Reference in New Issue
Block a user