Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)

docker 이미지 빌드 시 "RUN apt install ..." 명령어가 실패하는 이유

docker 이미지를 만들 때 apt-get udpate/upgrade도 해놓았는데요,

RUN apt-get update
RUN apt-get upgrade -y

이후 dockerfile의 내용에 sysstat을 설치하는 명령을 추가했더니,

RUN apt install sysstat -y

이렇게 오류가 발생합니다.

c:\temp> docker build -t py38agent-build-machine -f D:\data\build38.dockerfile .
[+] Building 20.5s (20/27)
 => [internal] load build definition from build38.dockerfile                                                                             0.9s
 => => transferring dockerfile: 1.09kB                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                        1.4s
 => => transferring context: 2B                                                                                                          0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                                                               1.4s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc          0.0s
 => [internal] load .dockerignore                                                                                                        0.0s
 => [internal] load build definition from build38.dockerfile                                                                             0.0s
 => [internal] load metadata for docker.io/library/python:3.8-slim-buster                                                                0.0s
 => [internal] load metadata for docker.io/library/golang:1.19.0                                                                         2.3s
 => [stage-1  1/17] FROM docker.io/library/python:3.8-slim-buster                                                                        0.0s
 => [internal] load build context                                                                                                        1.0s
 => => transferring context: 55B                                                                                                         0.0s
 => CACHED [go_builder 1/1] FROM docker.io/library/golang:1.19.0@sha256:d3f734e1f46ec36da8c1bce67cd48536138085289e24cfc8765f483c401b7d9  0.0s
 => CACHED [stage-1  2/17] WORKDIR /app                                                                                                  0.0s
 => CACHED [stage-1  3/17] RUN apt-get update                                                                                            0.0s
 => CACHED [stage-1  4/17] RUN apt-get upgrade -y                                                                                        0.0s
 => CACHED [stage-1  5/17] RUN apt-get install libpq-dev -y                                                                              0.0s
 => CACHED [stage-1  6/17] RUN apt install unzip -y                                                                                      0.0s
 => CACHED [stage-1  7/17] RUN python -m pip install --upgrade pip                                                                       0.0s
 => CACHED [stage-1  8/17] RUN apt install git -y                                                                                        0.0s
 => CACHED [stage-1  9/17] RUN apt install curl -y                                                                                       0.0s
 => ERROR [stage-1 10/17] RUN apt install net-tools sysstat nano iputils-ping -y                                                        12.6s
------
 > [stage-1 10/17] RUN apt install net-tools sysstat nano iputils-ping -y:
#18 5.307
#18 5.307 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#18 5.307
#18 5.467 Reading package lists...
#18 6.646 Building dependency tree...
#18 6.789 Reading state information...
#18 6.985 The following additional packages will be installed:
#18 6.985   bzip2 cron exim4-base exim4-config exim4-daemon-light file guile-2.2-libs
#18 6.986   libcap2 libcap2-bin libevent-2.1-6 libfribidi0 libgc1c2 libgnutls-dane0
#18 6.986   libgpm2 libgsasl7 libidn11 libkyotocabinet16v5 libltdl7 liblzo2-2
#18 6.987   libmagic-mgc libmagic1 libmailutils5 libmariadb3 libncurses6 libntlm0
#18 6.988   libpam-cap libpython2.7 libpython2.7-minimal libpython2.7-stdlib
#18 6.988   libsensors-config libsensors5 libunbound8 libwrap0 lsb-base mailutils
#18 6.991   mailutils-common mariadb-common mime-support mysql-common psmisc
#18 6.992   sensible-utils ucf xz-utils
#18 6.997 Suggested packages:
#18 6.997   bzip2-doc anacron logrotate checksecurity exim4-doc-html | exim4-doc-info
#18 6.997   eximon4 spf-tools-perl swaks dns-root-data gpm lm-sensors mailutils-mh
#18 6.997   mailutils-doc spell isag
#18 7.733 The following NEW packages will be installed:
#18 7.733   bzip2 cron exim4-base exim4-config exim4-daemon-light file guile-2.2-libs
#18 7.734   iputils-ping libcap2 libcap2-bin libevent-2.1-6 libfribidi0 libgc1c2
#18 7.734   libgnutls-dane0 libgpm2 libgsasl7 libidn11 libkyotocabinet16v5 libltdl7
#18 7.735   liblzo2-2 libmagic-mgc libmagic1 libmailutils5 libmariadb3 libncurses6
#18 7.736   libntlm0 libpam-cap libpython2.7 libpython2.7-minimal libpython2.7-stdlib
#18 7.739   libsensors-config libsensors5 libunbound8 libwrap0 lsb-base mailutils
#18 7.739   mailutils-common mariadb-common mime-support mysql-common nano net-tools
#18 7.739   psmisc sensible-utils sysstat ucf xz-utils
#18 7.906 0 upgraded, 47 newly installed, 0 to remove and 0 not upgraded.
#18 7.906 Need to get 17.8 MB of archives.
#18 7.906 After this operation, 89.4 MB of additional disk space will be used.
#18 7.906 Get:1 http://deb.debian.org/debian buster/main amd64 sensible-utils all 0.0.12 [15.8 kB]
#18 7.906 Get:2 http://security.debian.org/debian-security buster/updates/main amd64 xz-utils amd64 5.2.4-1+deb10u1 [183 kB]
#18 7.929 Get:3 http://deb.debian.org/debian buster/main amd64 lsb-base all 10.2019051400 [28.4 kB]
#18 7.956 Get:4 http://deb.debian.org/debian buster/main amd64 cron amd64 3.0pl1-134+deb10u1 [99.0 kB]
#18 8.024 Get:5 http://deb.debian.org/debian buster/main amd64 libcap2 amd64 1:2.25-2 [17.6 kB]
#18 8.024 Get:6 http://deb.debian.org/debian buster/main amd64 iputils-ping amd64 3:20180629-2+deb10u2 [43.4 kB]
#18 8.025 Get:7 http://deb.debian.org/debian buster/main amd64 nano amd64 3.2-3 [544 kB]
#18 8.108 Get:8 http://deb.debian.org/debian buster/main amd64 bzip2 amd64 1.0.6-9.2~deb10u1 [48.4 kB]
#18 8.112 Get:9 http://deb.debian.org/debian buster/main amd64 libmagic-mgc amd64 1:5.35-4+deb10u2 [242 kB]
#18 8.185 Get:10 http://deb.debian.org/debian buster/main amd64 libmagic1 amd64 1:5.35-4+deb10u2 [118 kB]
#18 8.244 Get:11 http://deb.debian.org/debian buster/main amd64 file amd64 1:5.35-4+deb10u2 [66.4 kB]
#18 8.255 Get:12 http://deb.debian.org/debian buster/main amd64 mime-support all 3.62 [37.2 kB]
#18 8.259 Get:13 http://deb.debian.org/debian buster/main amd64 ucf all 3.0038+nmu1 [69.0 kB]
#18 8.283 Get:14 http://deb.debian.org/debian buster/main amd64 exim4-config all 4.92-8+deb10u6 [324 kB]
#18 8.327 Get:15 http://deb.debian.org/debian buster/main amd64 exim4-base amd64 4.92-8+deb10u6 [1137 kB]
#18 8.536 Get:16 http://deb.debian.org/debian buster/main amd64 libevent-2.1-6 amd64 2.1.8-stable-4 [177 kB]
#18 8.565 Get:17 http://deb.debian.org/debian buster/main amd64 libunbound8 amd64 1.9.0-2+deb10u2 [462 kB]
#18 8.966 Err:18 http://deb.debian.org/debian buster/main amd64 libgnutls-dane0 amd64 3.6.7-4+deb10u7
#18 8.966   404  Not Found [IP: 146.75.50.132 80]
#18 8.966 Get:19 http://deb.debian.org/debian buster/main amd64 exim4-daemon-light amd64 4.92-8+deb10u6 [584 kB]
#18 9.065 Get:20 http://deb.debian.org/debian buster/main amd64 libgc1c2 amd64 1:7.6.4-0.4 [224 kB]
#18 9.117 Get:21 http://deb.debian.org/debian buster/main amd64 libltdl7 amd64 2.4.6-9 [390 kB]
#18 9.156 Get:22 http://deb.debian.org/debian buster/main amd64 libncurses6 amd64 6.1+20181013-2+deb10u2 [102 kB]
#18 9.172 Get:23 http://deb.debian.org/debian buster/main amd64 guile-2.2-libs amd64 2.2.4+1-2+deb10u1 [4968 kB]
#18 9.781 Get:24 http://deb.debian.org/debian buster/main amd64 libcap2-bin amd64 1:2.25-2 [28.8 kB]
#18 10.20 Ign:25 http://deb.debian.org/debian buster/main amd64 libfribidi0 amd64 1.0.5-3.1+deb10u1
#18 10.21 Get:26 http://deb.debian.org/debian buster/main amd64 libgpm2 amd64 1.20.7-5 [35.1 kB]
#18 10.22 Get:27 http://deb.debian.org/debian buster/main amd64 libidn11 amd64 1.33-2.2 [116 kB]
#18 10.24 Get:28 http://deb.debian.org/debian buster/main amd64 libntlm0 amd64 1.5-1+deb10u1 [22.7 kB]
#18 10.25 Get:29 http://deb.debian.org/debian buster/main amd64 libgsasl7 amd64 1.8.0-8+b2 [207 kB]
#18 10.26 Get:25 http://deb.debian.org/debian buster/main amd64 libfribidi0 amd64 1.0.5-3.1+deb10u1 [63.7 kB]
#18 10.31 Get:30 http://deb.debian.org/debian buster/main amd64 liblzo2-2 amd64 2.10-0.1 [56.1 kB]
#18 10.31 Get:31 http://deb.debian.org/debian buster/main amd64 libkyotocabinet16v5 amd64 1.2.76-4.2+b1 [298 kB]
#18 10.34 Get:32 http://deb.debian.org/debian buster/main amd64 mailutils-common all 1:3.5-4 [689 kB]
#18 10.43 Get:33 http://deb.debian.org/debian buster/main amd64 mysql-common all 5.8+1.0.5 [7324 B]
#18 10.44 Get:34 http://deb.debian.org/debian buster/main amd64 mariadb-common all 1:10.3.34-0+deb10u1 [33.0 kB]
#18 10.45 Get:35 http://deb.debian.org/debian buster/main amd64 libmariadb3 amd64 1:10.3.34-0+deb10u1 [173 kB]
#18 10.48 Get:36 http://deb.debian.org/debian buster/main amd64 libpython2.7-minimal amd64 2.7.16-2+deb10u1 [395 kB]
#18 10.51 Get:37 http://deb.debian.org/debian buster/main amd64 libpython2.7-stdlib amd64 2.7.16-2+deb10u1 [1912 kB]
#18 10.75 Get:38 http://deb.debian.org/debian buster/main amd64 libpython2.7 amd64 2.7.16-2+deb10u1 [1036 kB]
#18 10.89 Get:39 http://deb.debian.org/debian buster/main amd64 libmailutils5 amd64 1:3.5-4 [880 kB]
#18 10.99 Get:40 http://deb.debian.org/debian buster/main amd64 libpam-cap amd64 1:2.25-2 [14.3 kB]
#18 10.99 Get:41 http://deb.debian.org/debian buster/main amd64 libsensors-config all 1:3.5.0-3 [31.6 kB]
#18 11.00 Get:42 http://deb.debian.org/debian buster/main amd64 libsensors5 amd64 1:3.5.0-3 [52.6 kB]
#18 11.01 Get:43 http://deb.debian.org/debian buster/main amd64 libwrap0 amd64 7.6.q-28 [58.7 kB]
#18 11.02 Get:44 http://deb.debian.org/debian buster/main amd64 mailutils amd64 1:3.5-4 [585 kB]
#18 11.11 Get:45 http://deb.debian.org/debian buster/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1 [248 kB]
#18 11.15 Get:46 http://deb.debian.org/debian buster/main amd64 psmisc amd64 23.2-1+deb10u1 [126 kB]
#18 11.17 Get:47 http://deb.debian.org/debian buster/main amd64 sysstat amd64 12.0.3-2 [562 kB]
#18 11.22 E: Failed to fetch http://deb.debian.org/debian/pool/main/g/gnutls28/libgnutls-dane0_3.6.7-4+deb10u7_amd64.deb  404  Not Found [IP: 146.75.50.132 80]
#18 11.22 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
#18 11.22 Fetched 17.5 MB in 3s (5096 kB/s)
------
executor failed running [/bin/sh -c apt install net-tools sysstat nano iputils-ping -y]: exit code: 100

그런데, 위의 메시지를 확인해 보면 재미있는 점이 있습니다. 바로 ""RUN apt-get update/upgrade" 명령어도 다름 아닌 "CACHED" 처리되었다는 점입니다.

...[생략]...
 => CACHED [stage-1  2/17] WORKDIR /app                                                                                                  0.0s
 => CACHED [stage-1  3/17] RUN apt-get update                                                                                            0.0s
 => CACHED [stage-1  4/17] RUN apt-get upgrade -y                                                                                        0.0s
 => CACHED [stage-1  5/17] RUN apt-get install libpq-dev -y                                                                              0.0s
...[생략]...

따라서 cache를 이용하지 않도록 만들어야 하는데요, 이를 위해 "--no-cache" 옵션을 (실패할 때마다 한 번씩만) 추가하면 됩니다.

c:\temp> docker build --no-cache=true -t py38agent-build-machine -f D:\data\build38.dockerfile .
[+] Building 36.4s (13/27)
 => [internal] load build definition from build38.dockerfile                                                                             2.1s
 => => transferring dockerfile: 1.09kB                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                        1.4s
 => => transferring context: 2B                                                                                                          0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                                                               1.3s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc          0.0s
 => [internal] load build definition from build38.dockerfile                                                                             0.0s
 => [internal] load .dockerignore                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/golang:1.19.0                                                                         1.3s
 => [internal] load metadata for docker.io/library/python:3.8-slim-buster                                                                0.0s
 => [stage-1  1/17] FROM docker.io/library/python:3.8-slim-buster                                                                        0.0s
 => [internal] load build context                                                                                                        1.0s
 => => transferring context: 55B                                                                                                         0.0s
 => CACHED [go_builder 1/1] FROM docker.io/library/golang:1.19.0@sha256:d3f734e1f46ec36da8c1bce67cd48536138085289e24cfc8765f483c401b7d9  0.1s
 => CACHED [stage-1  2/17] WORKDIR /app                                                                                                  0.0s
 => [stage-1  3/17] RUN apt-get update                                                                                                   8.0s
 => [stage-1  4/17] RUN apt-get upgrade -y                                                                                              20.6s
 => => # Setting up base-files (10.3+deb10u13) ...
 => => # Installing new version of config file /etc/debian_version ...
 => => # (Reading database ... 6840 files and directories currently installed.)
 => => # Preparing to unpack .../archives/dpkg_1.19.8_amd64.deb ...
 => => # Unpacking dpkg (1.19.8) over (1.19.7) ...
 => => # Setting up dpkg (1.19.8) ...




이 현상 덕분에 지난번에 겪었던 그 글의 원인이 밝혀집니다. ^^;

Linux - apt와 apt-get의 차이
; https://www.sysnet.pe.kr/2/0/13075

그러니까, 그때 당시에 "RUN apt update/upgrade"는 CACHED 처리되었기 때문에 "apt install libpq-dev" 명령어가 실패했던 것입니다. 하지만, 명령어를 apt-get으로 바꾸면 CACHED가 아닌, 새롭게 이미지를 재구성했기 때문에 정상적으로 이미지 빌드가 되었던 것이고!




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 1/9/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13474정성태12/6/20232133개발 환경 구성: 690. 닷넷 코어/5+ 버전의 ilasm/ildasm 실행 파일 구하는 방법 - 두 번째 이야기
13473정성태12/5/20232325닷넷: 2179. C# - 값 형식(Blittable)을 메모리 복사를 이용해 바이트 배열로 직렬화/역직렬화파일 다운로드1
13472정성태12/4/20232155C/C++: 164. Visual C++ - InterlockedCompareExchange128 사용 방법
13471정성태12/4/20232183Copilot - To enable GitHub Copilot, authorize this extension using GitHub's device flow
13470정성태12/2/20232484닷넷: 2178. C# - .NET 8부터 COM Interop에 대한 자동 소스 코드 생성 도입파일 다운로드1
13469정성태12/1/20232193닷넷: 2177. C# - (Interop DLL 없이) CoClass를 이용한 COM 개체 생성 방법파일 다운로드1
13468정성태12/1/20232175닷넷: 2176. C# - .NET Core/5+부터 달라진 RCW(Runtime Callable Wrapper) 대응 방식파일 다운로드1
13467정성태11/30/20232170오류 유형: 882. C# - Unhandled exception. System.Runtime.InteropServices.COMException (0x800080A5)파일 다운로드1
13466정성태11/29/20232376닷넷: 2175. C# - DllImport 메서드의 AOT 지원을 위한 LibraryImport 옵션
13465정성태11/28/20232110개발 환경 구성: 689. MSBuild - CopyToOutputDirectory가 "dotnet publish" 시에는 적용되지 않는 문제파일 다운로드1
13464정성태11/28/20232230닷넷: 2174. C# - .NET 7부터 UnmanagedCallersOnly 함수 export 기능을 AOT 빌드에 통합파일 다운로드1
13463정성태11/27/20232144오류 유형: 881. Visual Studio - NU1605: Warning As Error: Detected package downgrade
13462정성태11/27/20232209오류 유형: 880. Visual Studio - error CS0246: The type or namespace name '...' could not be found
13461정성태11/26/20232258닷넷: 2173. .NET Core 3/5+ 기반의 COM Server를 registry 등록 없이 사용하는 방법파일 다운로드1
13460정성태11/26/20232224닷넷: 2172. .NET 6+ 기반의 COM Server 내에 Type Library를 내장하는 방법파일 다운로드1
13459정성태11/26/20232207닷넷: 2171. .NET Core 3/5+ 기반의 COM Server를 기존의 regasm처럼 등록하는 방법파일 다운로드1
13458정성태11/26/20232212닷넷: 2170. .NET Core/5+ 기반의 COM Server를 tlb 파일을 생성하는 방법(tlbexp)
13457정성태11/25/20232164VS.NET IDE: 187. Visual Studio - 16.9 버전부터 추가된 "Display inline type hints" 옵션
13456정성태11/25/20232459닷넷: 2169. C# - OpenAI를 사용해 PDF 데이터를 대상으로 OpenAI 챗봇 작성 [1]파일 다운로드1
13455정성태11/25/20232339닷넷: 2168. C# - Azure.AI.OpenAI 패키지로 OpenAI 사용파일 다운로드1
13454정성태11/23/20232681닷넷: 2167. C# - Qdrant Vector DB를 이용한 Embedding 벡터 값 보관/조회 (Azure OpenAI) [1]파일 다운로드1
13453정성태11/23/20232217오류 유형: 879. docker desktop 설치 시 "Invalid JSON string. (Exception from HRESULT: 0x83750007)"
13452정성태11/22/20232296닷넷: 2166. C# - Azure OpenAI API를 이용해 사용자가 제공하는 정보를 대상으로 검색하는 방법파일 다운로드1
13451정성태11/21/20232431닷넷: 2165. C# - Azure OpenAI API를 이용해 ChatGPT처럼 동작하는 콘솔 응용 프로그램 제작파일 다운로드1
13450정성태11/21/20232253닷넷: 2164. C# - Octokit을 이용한 GitHub Issue 검색파일 다운로드1
13449정성태11/21/20232351개발 환경 구성: 688. Azure OpenAI 서비스 신청 방법
1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...