nginx-alpine:如何查看其 docker 文件

nginx-alpine: how to view its docker file

我有以下图片:nginx:1.19.0-alpine

我想了解它的 docker 文件。我检查了 https://github.com/nginxinc/docker-nginx 但不明白如何检查

基本上我想改变 /docker-entrypoint.sh

目前是

#!/usr/bin/env sh
# vim:sw=4:ts=4:et

set -e

if [ "" = "nginx" -o "" = "nginx-debug" ]; then
    if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
        echo "[=11=]: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"

        echo "[=11=]: Looking for shell scripts in /docker-entrypoint.d/"
        find "/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
            case "$f" in
                *.sh)
                    if [ -x "$f" ]; then
                        echo "[=11=]: Launching $f";
                        "$f"
                    else
                        # warn on shell scripts without exec bit
                        echo "[=11=]: Ignoring $f, not executable";
                    fi
                    ;;
                *) echo "[=11=]: Ignoring $f";;
            esac
        done

        echo "[=11=]: Configuration complete; ready for start up"
    else
        echo "[=11=]: No files found in /docker-entrypoint.d/, skipping configuration"
    fi
fi

# Handle enabling SSL
if [ "$ENABLE_SSL" = "True" ]; then
  echo "Enabling SSL support!"
  cp /etc/nginx/configs/default_ssl.conf /etc/nginx/conf.d/default.conf
fi


exec "$@"

我要它修改为

#!/usr/bin/env sh
# vim:sw=4:ts=4:et

set -x -o verbose;

echo 

if [ "" = "nginx" -o "" = "nginx-debug" ]; then
    if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
        echo "[=12=]: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"

        echo "[=12=]: Looking for shell scripts in /docker-entrypoint.d/"
        find "/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
            case "$f" in
                *.sh)
                    if [ -x "$f" ]; then
                        echo "[=12=]: Launching $f";
                        "$f"
                    else
                        # warn on shell scripts without exec bit
                        echo "[=12=]: Ignoring $f, not executable";
                    fi
                    ;;
                *) echo "[=12=]: Ignoring $f";;
            esac
        done

        echo "[=12=]: Configuration complete; ready for start up"
    else
        echo "[=12=]: No files found in /docker-entrypoint.d/, skipping configuration"
    fi
fi

# Handle enabling SSL
if [ "$ENABLE_SSL" = "True" ]; then
  echo "Enabling SSL support!"
  cp /etc/nginx/configs/default_ssl.conf /etc/nginx/conf.d/default.conf
fi

exec "$@"

我看到正在传递 $1。但是不知道要传递什么

通常,来自 Dockerfile 的 CMD 作为参数发送到 ENTRYPOINT。在生成的 Dockerfile 中(当前 alpine 可在此处找到:https://github.com/nginxinc/docker-nginx/blob/master/stable/alpine/Dockerfile),可以看到 CMD 为 CMD ["nginx", "-g", "daemon off;"]。 所以在正常使用中,入口点脚本的参数是“nginx”、“-g”和“daemon off;”。

由于第一个参数是“nginx”,脚本将进入 if 块和 运行 代码。

如果您想 运行 不同的命令,可以使用 if 。例如,如果你想输入 shell 并在图像中环顾四周,你可以输入 docker run -it nginx:alpine /bin/sh。现在 entrypoint.sh 脚本的参数只是 "/bin/sh" 而现在脚本不会输入 if-block.

如果你想构建你自己的镜像修改版本,你可以 fork https://github.com/nginxinc/docker-nginx/ 并从你自己的 repo 版本构建。

如果您需要 1.19 版本的 Dockerfile,则必须查看存储库中的旧版本。 1.19.0 版本在这里:https://github.com/nginxinc/docker-nginx/blob/1.19.0/stable/alpine/Dockerfile