为什么要删除不需要的程序包(docker构建)?

时间:2019-03-27 21:24:23

标签: docker

因此,我正在使用以下Dockerfile构建我的Docker

# dummy base, which contains R
ARG MY_BASE_IMAGE=r-base
FROM ${MY_BASE_IMAGE}

ARG KING_URL="http://people.virginia.edu/~wc9c/KING/executables/Linux-king215.tar.gz"
ARG PLINK2_URL="https://github.com/chrchang/plink-ng/releases/download/2019/plink2_linux_x86_64_20190107.zip"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -qqy update --fix-missing && \
    apt-get -qqy dist-upgrade && \
    apt-get -qqy install --no-install-recommends \
                 wget unzip && \
    cd /tmp && \
    wget -q ${KING_URL} && \
    tar -xzf Linux-king215.tar.gz -C /usr/local/bin && \
    wget -q ${PLINK2_URL} && \
    unzip plink2_linux_x86_64_20190107.zip -d /usr/local/bin && \
    cd -- && \
    apt-get -qqy remove wget unzip && \
    rm -rf /tmp/* \
           /var/tmp/* \
           /var/cache/apt/* \
           /var/lib/apt/lists/* \
           /usr/share/man/?? \
           /usr/share/man/??_*

但是,除非我明确删除行apt-get -qqy remove wget unzip,否则这似乎删除了R。

我很难理解为什么。帮助非常感谢!


更新

我已经更深入地挖掘,并发现如果我运行apt-get -qqy remove wget,一切都会好起来的。

但是!如果我apt-get -qqy remove unzip,请返回以下的旧怪异行为:

Removing littler (0.3.7-2) ...
Removing r-base (3.5.3-1) ...
Removing r-recommended (3.5.3-1) ...
Removing r-cran-mgcv (1.8-28-1) ...
Removing r-base-dev (3.5.3-1) ...
Removing r-cran-littler (0.3.7-2) ...
Removing r-cran-boot (1.3-20-2) ...
Removing r-cran-class (7.3-15-1) ...
Removing r-cran-cluster (2.0.7-1-1+b3) ...
Removing r-cran-codetools (0.2-16-1) ...
Removing r-cran-foreign (0.8.71-1) ...
Removing r-cran-kernsmooth (2.23-15-3+b4) ...
Removing r-cran-nlme (3.1.137-1+b3) ...
Removing r-cran-mass (7.3-51.1-1) ...
Removing r-cran-nnet (7.3-12-2+b2) ...
Removing r-cran-rpart (4.1-13-1+b1) ...
Removing r-cran-spatial (7.3-11-2+b2) ...
Removing r-cran-survival (2.43-3-1) ...
Removing r-cran-matrix (1.2-17-1) ...
Removing r-cran-lattice (0.20-38-1) ...
Removing r-base-core (3.5.3-1) ...
Removing unzip (6.0-22) ...

1 个答案:

答案 0 :(得分:1)

听起来好像解压缩是R包的依赖项。由于您要删除zip文件,因此还需要删除所有依赖zip文件的文件。这是程序包管理器的典型行为。

您可以使用apt-cache dotty命令查看软件包的依赖关系树,该命令将在dot format中输出依赖关系。运行apt-cache dotty r-base显示:

r-base -> r-base-core
r-base-core -> unzip