【问题标题】:Why does my Dockerfile block from executing?为什么我的 Dockerfile 阻止执行?
【发布时间】:2021-10-18 16:01:31
【问题描述】:

Dockerfile:

FROM continuumio/miniconda:latest

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

RUN apt-get --allow-releaseinfo-change update && apt-get upgrade -y && apt-get install -qqy \
    wget \
    bzip2 \
    graphviz \
    curl

RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs && apt-get install -y npm

RUN mkdir -p /backend

COPY ./backend/requirements.yml /backend/requirements.yml

RUN /opt/conda/bin/conda env create -f /backend/requirements.yml

ENV PATH /opt/conda/envs/dacheting_backend/bin:$PATH

RUN echo "source activate dacheting_backend" >~/.bashrc

RUN mkdir -p /scripts

COPY ./scripts /scripts

RUN chmod +x ./scripts*

COPY ./backend /backend

RUN mkdir -p /frontend

RUN mkdir -p /frontend_tmp

COPY ./frontend /frontend_tmp

WORKDIR frontend_tmp

RUN npm i

RUN npm run build

WORKDIR /backend

当我尝试运行 docker build -t xxxx:latest . 时,出现以下错误:

错误 [3/18] 运行 curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y 52.2s ------ 取决于:node-write-file-atomic (>= 2.3~) 但它不会被安装 E: 无法纠正问题,你持有损坏的包。

(我得到了很多其他“取决于:....但它不会是 安装”)

--

我尝试寻找解决方案并使用了不同的方面,但没有任何效果。

【问题讨论】:

    标签: node.js docker dockerfile


    【解决方案1】:

    我尝试了这个版本,做了一些小的改动:

    FROM continuumio/miniconda:latest
    
    ENV LANG=C.UTF-8
    ENV LC_ALL=C.UTF-8
    
    RUN apt-get update --allow-releaseinfo-change \
     && apt-get install --assume-yes --no-install-recommends --quiet \
            curl \
            lsb-release \
            gnupg \
     && apt-get clean all
    
    RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
     && apt-get install --assume-yes --no-install-recommends --quiet \
            nodejs
    

    没有发现问题。

    输出:

    $ docker build -t stackoverflow -f Dockerfile.curl 
    STEP 1/5: FROM continuumio/miniconda:latest
    STEP 2/5: ENV LANG=C.UTF-8
    --> Using cache f8fc7d943e2c988c66c1048d2524de30c010244b02390f561aae07e234a924bf
    --> f8fc7d943e2
    STEP 3/5: ENV LC_ALL=C.UTF-8
    --> Using cache b6df639a53a673fda399433b9771b04463c232b7f6b59510ac7dc9e0db8c9cb9
    --> b6df639a53a
    STEP 4/5: RUN apt-get update --allow-releaseinfo-change  && apt-get install --assume-yes --no-install-recommends --quiet         curl         lsb-release         gnupg  && apt-get clean all
    Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
    
    [...]
    
    STEP 5/5: RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -  && apt-get install --assume-yes --no-install-recommends --quiet         nodejs
    
    ## Installing the NodeSource Node.js 14.x repo...
    
    
    ## Populating apt-get cache...
    
    + apt-get update
    Hit:1 http://security.debian.org/debian-security buster/updates InRelease
    Hit:2 http://deb.debian.org/debian buster InRelease
    Hit:3 http://deb.debian.org/debian buster-updates InRelease
    Reading package lists...
    
    ## Confirming "buster" is supported...
    
    + curl -sLf -o /dev/null 'https://deb.nodesource.com/node_14.x/dists/buster/Release'
    
    ## Adding the NodeSource signing key to your keyring...
    
    + curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null
    
    ## Creating apt sources list file for the NodeSource Node.js 14.x repo...
    
    + echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x buster main' > /etc/apt/sources.list.d/nodesource.list
    + echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x buster main' >> /etc/apt/sources.list.d/nodesource.list
    
    ## Running `apt-get update` for you...
    
    + apt-get update
    Hit:1 http://deb.debian.org/debian buster InRelease
    Hit:2 http://security.debian.org/debian-security buster/updates InRelease
    Hit:3 http://deb.debian.org/debian buster-updates InRelease
    Get:4 https://deb.nodesource.com/node_14.x buster InRelease [4584 B]
    Get:5 https://deb.nodesource.com/node_14.x buster/main amd64 Packages [768 B]
    Fetched 5352 B in 1s (3748 B/s)
    Reading package lists...
    
    ## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
    ## You may also need development tools to build native addons:
         sudo apt-get install gcc g++ make
    ## To install the Yarn package manager, run:
         curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
         echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
         sudo apt-get update && sudo apt-get install yarn
    
    
    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following NEW packages will be installed:
      nodejs
    0 upgraded, 1 newly installed, 0 to remove and 62 not upgraded.
    Need to get 25.0 MB of archives.
    After this operation, 122 MB of additional disk space will be used.
    Get:1 https://deb.nodesource.com/node_14.x buster/main amd64 nodejs amd64 14.18.1-deb-1nodesource1 [25.0 MB]
    debconf: delaying package configuration, since apt-utils is not installed
    Fetched 25.0 MB in 6s (4055 kB/s)
    Selecting previously unselected package nodejs.
    (Reading database ... 13510 files and directories currently installed.)
    Preparing to unpack .../nodejs_14.18.1-deb-1nodesource1_amd64.deb ...
    Unpacking nodejs (14.18.1-deb-1nodesource1) ...
    Setting up nodejs (14.18.1-deb-1nodesource1) ...
    COMMIT stackoverflow
    --> c9d22106329
    Successfully tagged localhost/stackoverflow:latest
    c9d2210632965f49408570dd2808cf8dfbe50d19ffce58972865a9a9e0a6d93b
    

    【讨论】:

    • 非常感谢!您介意解释一下我做错了什么以及您的更改意味着什么吗?
    • npm 二进制文件由从 deb.nodesource.com 下载的包 nodejs 提供。如果你尝试安装 Debian 提供的 npm 包,你会遇到包冲突。
    猜你喜欢
    • 2011-08-16
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 2019-11-07
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2016-06-09
    相关资源
    最近更新 更多