为什么在 docker build 中运行 apt-get 时会出现“内存不足”的情况

问题描述 投票:0回答:1

我正在尝试在我的 docker 容器中安装 ca 证书,但确实没有运气。 我可以

apt-get update
,并且可以安装 一些 其他软件包,但不能安装 curl 或 ca 证书。此外,如果我运行 ubuntu 基础容器并
exec -it
进入其中,我可以在那里
apt-get install
ca 证书。

Dockerfile:

FROM ubuntu:latest
ENV http_proxy=http://my_proxy_that_probably_doesnt_matter

RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y ca-certificates

重击:

docker build .

这是此步骤的日志:

RUN apt-get install -y ca-certificates:                                                                                 
0.275 Reading package lists...                                                                                                   
1.169 Building dependency tree...
1.346 Reading state information...
1.600 The following additional packages will be installed:
1.600   openssl
1.628 The following NEW packages will be installed:
1.630   ca-certificates openssl
1.733 0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
1.733 Need to get 1161 kB of archives.
1.733 After this operation, 2324 kB of additional disk space will be used.
1.733 Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 openssl amd64 3.0.13-0ubuntu3 [1002 kB]
1.753 Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 ca-certificates all 20240203 [159 kB]
1.909 debconf: unable to initialize frontend: Dialog
1.909 debconf: (TERM is not set, so the dialog frontend is not usable.)
1.909 debconf: falling back to frontend: Readline
1.910 debconf: unable to initialize frontend: Readline
1.910 debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC entries checked: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 8, <STDIN> line 2.)
1.910 debconf: falling back to frontend: Teletype
1.917 dpkg-preconfigure: unable to re-open stdin: 
1.963 Fetched 1161 kB in 0s (10.4 MB/s)
1.978 Selecting previously unselected package openssl.
(Reading database ... 4937 files and directories currently installed.)
1.986 Preparing to unpack .../openssl_3.0.13-0ubuntu3_amd64.deb ...
1.987 Unpacking openssl (3.0.13-0ubuntu3) ...
2.032 Selecting previously unselected package ca-certificates.
2.033 Preparing to unpack .../ca-certificates_20240203_all.deb ...
2.034 Unpacking ca-certificates (20240203) ...
2.089 Setting up openssl (3.0.13-0ubuntu3) ...
2.093 Setting up ca-certificates (20240203) ...
2.179 debconf: unable to initialize frontend: Dialog
2.179 debconf: (TERM is not set, so the dialog frontend is not usable.)
2.179 debconf: falling back to frontend: Readline
2.179 debconf: unable to initialize frontend: Readline
2.179 debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC entries checked: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.38.2 /usr/local/share/perl/5.38.2 /usr/lib/x86_64-linux-gnu/perl5/5.38 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.38 /usr/share/perl/5.38 /usr/local/lib/site_perl) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 8.)
2.179 debconf: falling back to frontend: Teletype
2.806 Updating certificates in /etc/ssl/certs...
3.577 out of memory
3.578 out of memory
3.578 out of memory
3.578 out of memory
3.578 out of memory
3.578 out of memory
3.578 out of memory
3.578 out of memory
3.578 out of memory
3.579 out of memory
3.579 out of memory
3.579 out of memory
3.579 out of memory
3.579 out of memory
3.579 out of memory
3.579 out of memory
3.579 out of memory
3.580 out of memory
3.580 out of memory
3.580 out of memory
3.580 out of memory
3.580 out of memory
3.580 out of memory
3.580 out of memory
3.581 out of memory
3.581 out of memory
3.581 out of memory
3.581 out of memory
3.581 out of memory
3.581 out of memory
3.581 out of memory
3.582 out of memory
3.582 out of memory
3.582 out of memory
3.582 out of memory
3.582 out of memory
3.582 out of memory
3.583 out of memory
3.583 out of memory
3.583 out of memory
3.583 out of memory
3.583 out of memory
3.584 out of memory
3.584 out of memory
3.584 out of memory
3.585 out of memory
3.585 out of memory
3.585 out of memory
3.585 out of memory
3.585 out of memory
3.585 out of memory
3.585 out of memory
3.585 out of memory
3.586 out of memory
3.586 out of memory
3.586 out of memory
3.586 out of memory
3.586 out of memory
3.586 out of memory
3.586 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.587 out of memory
3.588 out of memory
3.588 out of memory
3.588 out of memory
3.588 out of memory
3.588 out of memory
3.588 out of memory
3.588 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.589 out of memory
3.590 out of memory
3.590 out of memory
3.590 out of memory
3.590 out of memory
3.590 out of memory
3.590 out of memory
3.590 out of memory
3.590 out of memory
3.591 out of memory
3.591 out of memory
3.591 out of memory
3.591 out of memory
3.591 out of memory
3.591 out of memory
3.591 out of memory
3.591 out of memory
3.591 out of memory
3.592 out of memory
3.592 out of memory
3.592 out of memory
3.592 out of memory
3.592 out of memory
3.592 out of memory
3.592 out of memory
3.592 out of memory
3.593 out of memory
3.593 out of memory
3.593 out of memory
3.593 out of memory
3.593 out of memory
3.593 out of memory
3.593 out of memory
3.593 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.594 out of memory
3.595 out of memory
3.595 out of memory
3.595 out of memory
3.595 out of memory
3.595 out of memory
3.595 out of memory
3.595 out of memory
3.595 out of memory
3.596 out of memory
3.596 out of memory
3.596 out of memory
3.596 out of memory
3.596 out of memory
3.596 out of memory
3.596 out of memory
3.610 dpkg: error processing package ca-certificates (--configure):
3.610  installed ca-certificates package post-installation script subprocess returned error exit status 146
3.613 Errors were encountered while processing:
3.613  ca-certificates
3.630 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
Dockerfile:7
--------------------
   5 |     RUN apt-get update
   6 |     RUN apt-get install -y dialog apt-utils gnupg lsb-release
   7 | >>> RUN apt-get install -y ca-certificates
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get install -y ca-certificates" did not complete successfully: exit code: 100
docker ubuntu build apt-get
1个回答
0
投票

有时,当构建超出 docker 容器的限制时,就会出现此错误。当您尝试构建时,您可以使用

-m
选项指定新的限制。

docker build -f Dockerfile -m 4g .
© www.soinside.com 2019 - 2024. All rights reserved.