Dockerfile: 安装 CRIU 并配置代理

本 Dockerfile 提供了在 Docker 容器中安装 CRIU 工具的步骤,并展示了如何配置 HTTP 和 HTTPS 代理。

FROM base AS criu

ARG DEBIAN_FRONTEND

ENV http_proxy='http://192.168.44.37:7890'
ENV https_proxy='https://192.168.44.37:7890'

ADD --chmod=0644 'https://download.opensuse.org/repositories/devel:/tools:/criu/Debian_11/Release.key' /etc/apt/trusted.gpg.d/criu.gpg.asc

RUN --mount=type=cache,sharing=locked,id=moby-criu-aptlib,target=/var/lib/apt \
    --mount=type=cache,sharing=locked,id=moby-criu-aptcache,target=/var/cache/apt \
        echo 'deb https://download.opensuse.org/repositories/devel:/tools:/criu/Debian_11/ /' > /etc/apt/sources.list.d/criu.list \
        && apt update \
        && apt install -y --no-install-recommends criu \
        && install -D /usr/sbin/criu /build/criu

关于 --no-check-certificate

您可能想知道何时以及如何在 Dockerfile 中使用 --no-check-certificate 选项。

在这个 Dockerfile 中,没有使用任何 HTTPS URL,因此不需要使用 --no-check-certificate 选项。

如果您需要在使用 HTTPS URL 时禁用 SSL 证书验证,可以在 ADD 命令中使用 --no-check-certificate 选项。例如:

ADD --no-check-certificate 'https://example.com/file.tar.gz' /tmp/file.tar.gz

重要提示: 强烈建议不要禁用 SSL 证书验证,因为这会使您的应用程序容易受到中间人攻击。

希望本指南对您有所帮助!如果您有任何问题或疑问,请随时提问。

Dockerfile: 安装 CRIU 并配置代理

原文地址: https://www.cveoy.top/t/topic/gS1d 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录