Nexus Docker proxy·group을 통해 이미지를 캐시하고 containerd 클라이언트를 연결한 기록이다. 저장소 설정, 런타임 mirror, 캐시 관측, 삭제 후 공간 회수를 순서대로 구분한다.

구성 순서는 upstream proxy와 group 준비, containerd의 유효 설정 확인, 캐시 사용 관측, 보존 정책에 따른 삭제와 공간 회수다. 이미지 저장 화면·패킷 필터·파일 개수는 각각 확인 범위가 다르므로 함께 읽어야 한다.

1. Proxy·Hosted·Group의 관계

Proxy는 원격 저장소의 아티팩트를 요청에 따라 받아 캐시한다. Hosted는 직접 push한 아티팩트를 관리한다. Group은 여러 멤버 저장소를 하나의 조회 endpoint로 묶는 논리적 통로다.

Group 자체가 별도의 모든 이미지 파일 복사본을 저장하는 저장소는 아니다. 조회한 아티팩트가 어느 proxy/hosted 멤버에 들어갔는지 함께 확인해야 한다.

Docker Hub 공식 이미지 경로는 library/nginx·library/httpd처럼 library namespace를 사용한다. docker.io/library/httpd:latest라는 이미지 이름과 registry-1.docker.io라는 실제 endpoint를 구분한다.

캡처의 설정·출력 기록 · 식별정보 제외
plain text
Nexus proxy 설정
Format: docker
Type: proxy
Remote storage: https://registry-1.docker.io
Docker Index: Use Docker Hub
Maximum component age: 1440
Maximum metadata age: 1440
Negative cache TTL: 1440
당시 upstream endpoint 목록
plain text
https://registry-1.docker.io
https://ghcr.io
https://public.ecr.aws
https://quay.io
https://registry.gitlab.com
https://registry.k8s.io

Docker Index·Foreign Layer·Negative Cache

Docker Index 설정은 Docker Hub 또는 해당 upstream의 검색·인증 관련 동작을 선택하는 설정이다. library 접두사를 임의로 바꾸는 설정으로 읽지 않는다.

Foreign Layer Caching은 외부 URL에 따로 호스팅된 foreign layer를 Nexus에서 캐시할지에 관한 옵션이다. 일반 이미지 레이어 캐시 전체를 켜는 유일한 스위치가 아니다.

Negative Cache는 upstream에서 없다고 확인한 항목의 결과를 TTL 동안 기억해 같은 실패 조회를 반복하지 않도록 한다. 외부망에서 온 클라이언트 요청을 전부 무시하는 기능이 아니다. upstream에 새 항목이 생겼는데 이전 not-found가 남는 경우 TTL·invalidate 동작을 확인한다.

당시에는 요청 문제를 조사하며 Negative Cache 옵션을 껐다고 적었다. 정확한 실패 요청과 TTL 변화 결과가 없어 모든 환경의 기본 해결책으로 삼을 수는 없다.

Docker proxy 설정 · Foreign layer · 캐시 필드와 TTL

2. Group의 멤버 순서와 이름 충돌

멤버 저장소를 등록한 group의 connector 포트를 클라이언트에 제공하는 구성이다. 이 기록의 예는 nexus.example.com:55000을 조회 통로로 사용한다.

캡처의 설정·출력 기록 · 식별정보 제외
plain text
Nexus group 설정
Format: docker
Type: group
HTTP connector: 55000
멤버: docker-hosted, registry.gitlab.com, quay.io, docker.io, registry.k8s.io, ghcr.io, public.ecr.aws

같은 경로가 여러 upstream에 존재하면 멤버 순서가 결과에 영향을 줄 수 있다. docker.io·quay.io·ghcr.io를 전부 같은 group으로 보낸다고 원본 registry namespace가 자동으로 분리되는 것은 아니다. containerd가 보낼 수 있는 ns query와 Nexus의 실제 처리도 확인해야 한다.

검증할 때는 요청 이미지의 원본 registry·repository 경로·tag/digest, 선택된 Nexus 멤버, 최종 digest를 함께 남긴다.

3. containerd 버전에 맞는 registry 설정

hosts.toml 기반 registry host 설정은 containerd 1.5부터 도입됐고 과거 CRI registry.mirrors/configs 방식은 deprecated됐다. 아래 config dump에서는 version=3과 예전 plugin 경로의 unknown key 경고가 함께 나타난다.

당시 containerd config dump 경고 전체
plain text
containerd config toml
root@bastion:~/deploy/2.nexus# containerd config dump
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key=registry plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry configs" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry configs docker.io" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry configs docker.io tls" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry configs my-repo:55000" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry configs my-repo:55000 tls" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry configs registry-1.docker.io" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry configs registry-1.docker.io tls" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors docker.io" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors ghcr.io" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors public.ecr.aws" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors quay.io" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors registry-1.docker.io" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors registry.gitlab.com" plugin=io.containerd.grpc.v1.cri
WARN[0000] Ignoring unknown key in TOML for plugin       error="strict mode: fields in the document are missing in the target struct" key="registry mirrors registry.k8s.io" plugin=io.containerd.grpc.v1.cri
version = 3
root = '/var/lib/containerd'

버전·config schema와 plugin 이름부터 맞춰야 한다. 기존 config.toml에 같은 TOML 테이블을 계속 append하면 중복·무시·충돌 문제가 생길 수 있다.

containerd 1.x의 config schema 2 예

toml
version = 2
[plugins."io.containerd.grpc.v1.cri".registry]
  config_path = "/etc/containerd/certs.d"

containerd 2.x의 config schema 3 예

toml
version = 3
[plugins."io.containerd.cri.v1.images".registry]
  config_path = "/etc/containerd/certs.d"

둘을 같은 설정 파일에 겹쳐 넣는 예가 아니다. 실제 버전·유효 plugin·현재 설정과 병합해 적용한다.

registry별 hosts.toml 예

docker.io의 host 설정 파일 경로는 /etc/containerd/certs.d/docker.io/hosts.toml이다. 실제 디렉터리·registry 이름과 파일 철자를 맞춰야 한다.

toml
server = "https://registry-1.docker.io"

[host."https://nexus.example.internal"]
  capabilities = ["pull", "resolve"]
  ca = "/etc/containerd/certs.d/docker.io/nexus-ca.crt"

이 예는 내부 Nexus HTTPS endpoint와 신뢰할 CA를 이미 준비한 경우다. resolve를 허용하면 그 mirror의 tag→digest 결정을 신뢰한다는 의미도 있으므로 의도에 맞게 선택한다.

host mirror 실패 시 server의 upstream으로 fallback할 수 있다. 외부 직접 접근 여부는 mirror뿐 아니라 server 선택과 네트워크 정책을 함께 적용한 경로에 달려 있다.

HTTP endpoint에는 TLS가 없으므로 skip_verify가 HTTP를 안전하게 만들지 않는다. skip_verify는 HTTPS 인증서 검증을 건너뛰는 옵션으로 정상 CA 설정과 구분한다.

containerd registry host 공식 설정

config_path 같은 데몬 설정 변경과 hosts 디렉터리의 갱신은 적용 방식이 다르다. 공식 host 설정 문서는 hosts 디렉터리 갱신에 containerd 재시작이 필요하지 않다고 설명한다. 모든 변경마다 무조건 재시작하지 말고 사용 버전의 동작을 확인한다.

구형 registry.mirrors 구성
plain text
# /etc/containerd/config.toml
cat << EOF >> /etc/containerd/config.toml
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
          endpoint = ["http://nexus.example.com:55000"]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."quay.io"]
          endpoint = ["http://nexus.example.com:55000"]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry.gitlab.com"]
          endpoint = ["http://nexus.example.com:55000"]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry.k8s.io"]
          endpoint = ["http://nexus.example.com:55000"]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."public.ecr.aws"]
          endpoint = ["http://nexus.example.com:55000"]
        [plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
          endpoint = ["http://nexus.example.com:55000"]
EOF
hosts.toml·인증서·재시작 구성 자료
plain text
# /etc/containred/certs.d/[도메인 명] ex) docker.io , ghrc,io, quay.io/hosts.toml

# 서버로 요청 온걸 host로 변경해서 요청 
server = "https://docker.io"
[host."http://nexus.example.com:55000"]
  capabilities = ["pull", "resolve"]
  skip_verify = true
  
  
  scp -r worker-1:/root/certs/* /etc/containerd/certs.d/
  systemctl restart containerd.service

nerdctl·ctr·CRI가 어느 hosts 디렉터리와 인증 설정을 쓰는지도 구분한다. 한 클라이언트의 pull 성공으로 kubelet의 CRI pull까지 검증됐다고 볼 수 없다.

nerdctl registry 설정

Nexus 컨테이너의 resolv.conf를 직접 바꾼 것은 일시적인 확인 메모다. 재생성 후 유지될 설정인지와 Docker/배포의 DNS 구성을 별도로 확인한다.

4. 캐시가 사용된다는 관측의 범위

첫 요청 뒤 해당 proxy에 이미지가 저장됐고, 재요청 때 tcpdump에서 upstream 연결이 보이지 않았다고 기록했다.

bash
tcpdump -i any host registry-1.docker.io and port 443 -n

이 필터는 특정 호스트·포트만 본다. 인증 endpoint·CDN·redirect 등 다른 연결은 빠질 수 있다. 캐시 재검증·tag 갱신·다른 digest 요청에서는 다시 upstream 요청이 발생할 수도 있다.

따라서 확인된 것은 해당 시험의 캐시 사용 정황이며 “모든 요청은 최초 한 번만 외부로 나간다”는 무기한 보장은 아니다.

문서 이미지
문서 이미지

캐시만으로 폐쇄망을 보장하려면 필요한 manifest·플랫폼별 layer·인증 경로를 준비한 뒤 실제 외부 단절 조건으로 시험하고 결과를 남긴다.

5. Skopeo는 별도의 이미지 복사 도구다

skopeo copy는 source와 destination을 명시해 이미지를 복사한다. pull-through cache와 달리 대상 hosted 저장소에 계획적으로 반입하는 데 쓸 수 있다.

bash
# 각 레지스트리에서 필요한 인증을 먼저 설정한다.
skopeo login nexus.example.internal

skopeo copy \
  docker://docker.io/ngoduykhanh/powerdns-admin:latest \
  docker://nexus.example.internal/ngoduykhanh/powerdns-admin:latest

실제 목적지의 hosted connector와 경로·권한을 맞춘다. multi-platform 전체를 옮길 때는 --all 등 선택과 최종 manifest digest를 따로 확인한다.

source와 destination의 TLS·인증 옵션은 별개다. --src-tls-verify와 --dest-tls-verify를 구분하고 각 endpoint에 맞는 인증을 전달한다. 과거 자격정보를 새 실행에 재사용하지 않는다.

당시 Skopeo 복사 메모 — 일부 미완성 인수·자격증명 비식별화
bash
skopeo copy docker://ngoduykhanh/powerdns-admin:latest docker://192.0.2.10:50000/ngoduykhanh/powerdns-admin:latest --dest-tls-verify=false --dest-creds 'REDACTED_USER:REDACTED_PASSWORD'

Skopeo의 TLS 검증과 인증은 출발지(--src-tls-verify, --src-creds)와 목적지(--dest-tls-verify, --dest-creds)에 각각 설정한다.

Skopeo copy 옵션

6. UI 삭제·Cleanup·Compact의 차이

아티팩트가 UI에서 사라지는 것과 파일 저장 공간이 회수되는 것은 다른 시점일 수 있다. Nexus는 soft delete 표시와 나중의 hard delete를 구분한다.

작업목적과 범위
Cleanup repositories using their associated policies저장소의 보존 정책에 맞는 컴포넌트를 soft delete한다.
Compact blob storesoft-deleted Blob의 공간을 영구적으로 회수하는 작업이다. 버전·backend·보존 기간에 따라 세부 동작이 다르다.
Docker - Delete unused manifests and imagesDocker의 tag·manifest 참조 관계상 더 이상 참조되지 않는 항목을 정리한다.
Docker - Delete incomplete uploads 등업로드 중단으로 남은 임시 자료 등 해당 task가 정의한 대상을 처리한다.
Rebuild/Repair 계열인덱스·메타데이터 복구를 위한 작업이다. 일반적인 물리 공간 회수와 같은 작업이 아니다.
정리 task는 이름과 format별 동작을 기준으로 확인한다. Maven·npm 패키지가 실제 애플리케이션에서 사용되는지까지 Nexus가 자동 추적해 판단한다고 가정하지 않는다.

Docker 정리는 운영 서비스의 digest 참조까지 알지 못할 수 있다. tag 없이 digest로 보존·배포하는 이미지도 업무 보존 정책과 대상 목록을 먼저 확인해야 한다. JAR 의존성 그래프를 이미지 정리 기준으로 사용하지 않는다.

정리의 일반 흐름은 보존 정책·대상 검토→해당 cleanup task→결과·보존 기간 확인→필요한 compact→실제 사용량 확인이다. 모든 환경에서 네 가지 task를 순서대로 강제 실행하는 절차는 아니다.

캡처의 설정·출력 기록 · 식별정보 제외
plain text
Nexus hosted 설정
Name: docker-hosted
Format: docker
Type: hosted
HTTP connector: 50000
URL: http://nexus.example.com:8081/repository/docker-hosted/
문서 이미지

Cleanup과 soft/hard delete · format별 task와 Docker digest 주의 · 공간 사용량 확인

7. .bytes와 .properties 개수만으로 사용 여부를 판단하지 않기

파일 기반 blob store의 .bytes는 데이터, .properties는 그 Blob의 속성 파일이다. .properties는 Nexus의 컴포넌트 DB 자체가 아니다. 한 쌍이 존재해도 soft-deleted 상태일 수 있어 “현재 쓰는 이미지”라고 판정할 수 없다.

하나의 이미지가 여러 layer·manifest Blob을 참조하고, Blob이 여러 manifest에서 공유될 수도 있다. 파일 개수와 이미지 개수는 1:1이 아니다.

속성 파일이 안 보이거나 data가 빠졌다면 불일치·미완료·손상 등 추가 조사 대상이다. 이를 근거로 .bytes를 수동 삭제하는 절차를 만들지 않는다. Compact 역시 모든 파일을 단순 DB 대조로 지우는 범용 orphan 탐지기라고 설명하지 않는다.

캡처의 설정·출력 기록 · 식별정보 제외
plain text
$ ls -al /srv/nexus-data/blobs/default/content/vol-01/chap-01
-rw-r--r--  1 200 200 21010098 Jun 17 08:21 BLOB_ID.bytes
-rw-r--r--  1 200 200      422 Jun 17 08:21 BLOB_ID.properties
캡처의 설정·출력 기록 · 식별정보 제외
plain text
# Blob 속성 발췌
@BlobStore.created-by=admin
size=21010098
@Bucket.repo-name=docker-hosted
creationTime=1750148465870
@BlobStore.created-by-ip=192.0.2.10
@BlobStore.content-type=application/vnd.docker.image.rootfs.diff.tar.gzip
@BlobStore.blob-name=v2/-/blobs/sha256:IMAGE_LAYER_DIGEST
문서 이미지

당시 파일 수 비교 명령은 아래와 같다. content 외부에서 검색하면 저장소 자체의 다른 properties 파일도 포함할 수 있다.

당시 확장자별 파일 수 비교
plain text
find . -name "*.properties" | wc -l
find . -name "*.bytes" | wc -l
캡처의 설정·출력 기록 · 식별정보 제외
plain text
$ find . -name '*.properties' | wc -l
2074
$ find . -name '*.bytes' | wc -l
2074
문서 이미지

이 결과는 두 확장자 파일 수의 관측이며 DB 참조 무결성·아티팩트 정상 pull을 증명하지 않는다. UI의 크기·task 결과·실제 파일 시스템 사용량과 보존 대상의 pull을 함께 확인한다.

Blob 저장·삭제 모델

8. 별도 구축 메모와 이어서 읽기

Jenkins·MinIO의 일부 chart·values에서 monitoring.coreos.com 계열 CRD를 참조해 kube-prometheus-stack을 준비한 기록이 있다. 이 의존성은 선택한 chart와 관측 옵션에 따른 구성이며, 별도의 오류·해결 출력은 남아 있지 않다.

프록시 앞단의 TLS·DNS 문제와 백업·복구는 각각 다음 문서로 이어진다.

HAProxy 앞단의 TLS·DNS 검증은 별도 기록으로 관리한다.

레지스트리 복제·백업·복구의 차이는 다음 문서에서 이어서 다룬다.

Nexus·Harbor DR: 복제·일관성 백업·Velero 복구