拉取镜像
IMAGE_REF=sonatype/nexus3:3.93.1
docker pull $IMAGE_REF
root@iZj6cabd0bkfnfa0be1b24Z:~# IMAGE_REF=sonatype/nexus3:3.93.1
root@iZj6cabd0bkfnfa0be1b24Z:~# docker pull $IMAGE_REF
3.93.1: Pulling from sonatype/nexus3
839c8610da0c: Pull complete
a475e1339823: Pull complete
11ae686f8532: Pull complete
db7a8d32ca8d: Pull complete
55afa1ecc21d: Pull complete
9efd2223e065: Pull complete
c5e3b62cb9ce: Pull complete
1bade7a438bb: Pull complete
85ff9f07a730: Download complete
Digest: sha256:20eff0386283951be6c494e3f82030dec06ff14d39da8aff7d001d3d6620ba85
Status: Downloaded newer image for sonatype/nexus3:3.93.1
docker.io/sonatype/nexus3:3.93.1
root@iZj6cabd0bkfnfa0be1b24Z:~#
镜像保存到本地
docker save -o tmp.tar $IMAGE_REF
ls -lha tmp.tar
root@iZj6cabd0bkfnfa0be1b24Z:~# docker save -o tmp.tar $IMAGE_REF
root@iZj6cabd0bkfnfa0be1b24Z:~# ls -lha tmp.tar
-rw------- 1 root root 448M Jun 22 12:17 tmp.tar
root@iZj6cabd0bkfnfa0be1b24Z:~#
查看镜像压缩包
tar -tf tmp.tar
root@iZj6cabd0bkfnfa0be1b24Z:~# tar -tf tmp.tar
blobs/
blobs/sha256/
blobs/sha256/11ae686f85329a2c95a3fc0311689c4de6eb455a8a27ba448f2df39c887ee177
blobs/sha256/1bade7a438bb5f920e0259ddec9571bcc915a14857deddaa9afe99f2489e9dc9
blobs/sha256/20eff0386283951be6c494e3f82030dec06ff14d39da8aff7d001d3d6620ba85
blobs/sha256/55afa1ecc21d2bb5e5045f32dafee56272ffd89860bac26f6c32123439af26a4
blobs/sha256/5a32d4f8ff6ec4737a8c664fee438bb9354d1204653fb890fef987e7972c0045
blobs/sha256/839c8610da0c69bc02b2c6d65253b6f4596f396e4f9c280c4100cbf3b7cb77d4
blobs/sha256/85ff9f07a730cb87055d903ef970f773aa1a9ffae971875a4bb9d4c79962c208
blobs/sha256/9506bf5a197a8d307263e78794dbbd45c9790858138e8fa45ff80e6eb953f6bb
blobs/sha256/982d7aa5a70fb8b01b8e17f1075c859073acfd58eb81232be0b7ddb64096cd7a
blobs/sha256/9efd2223e065e51729731155263ffcfc038b5316fe6319fff21818fc2cff099d
blobs/sha256/a475e133982362512935e16d27256ca1f54a9ffa6cdcc2823a22fd55dc26bf05
blobs/sha256/c5e3b62cb9ce7faf618255f0e0ea595d0a3bd8e2e7c1f2a7a918053f64adbe98
blobs/sha256/db7a8d32ca8da0602fd239a4623626b3b67206d7bd9338a12078169d267fe01f
blobs/sha256/e5d95731073243ee7590b3581e1c879e383443bff1d53fe9a7c783ebfc33807d
index.json
manifest.json
oci-layout
root@iZj6cabd0bkfnfa0be1b24Z:~#
查看 repositories
并非所有 Docker 镜像都有 repositories
tar -xOf tmp.tar repositories | jq
{
"xxx/xxx": {
"vx.y.z": "843887eca5993f978b55ae376d4eaba7d56ce5afdfdf6ec708bd1cdb49fb4473"
}
}
查看 manifest.json
tar -xOf tmp.tar manifest.json | jq
root@iZj6cabd0bkfnfa0be1b24Z:~# tar -xOf tmp.tar manifest.json | jq
[
{
"Config": "blobs/sha256/9506bf5a197a8d307263e78794dbbd45c9790858138e8fa45ff80e6eb953f6bb",
"RepoTags": [
"sonatype/nexus3:3.93.1"
],
"Layers": [
"blobs/sha256/55afa1ecc21d2bb5e5045f32dafee56272ffd89860bac26f6c32123439af26a4",
"blobs/sha256/a475e133982362512935e16d27256ca1f54a9ffa6cdcc2823a22fd55dc26bf05",
"blobs/sha256/db7a8d32ca8da0602fd239a4623626b3b67206d7bd9338a12078169d267fe01f",
"blobs/sha256/11ae686f85329a2c95a3fc0311689c4de6eb455a8a27ba448f2df39c887ee177",
"blobs/sha256/1bade7a438bb5f920e0259ddec9571bcc915a14857deddaa9afe99f2489e9dc9",
"blobs/sha256/9efd2223e065e51729731155263ffcfc038b5316fe6319fff21818fc2cff099d",
"blobs/sha256/c5e3b62cb9ce7faf618255f0e0ea595d0a3bd8e2e7c1f2a7a918053f64adbe98",
"blobs/sha256/839c8610da0c69bc02b2c6d65253b6f4596f396e4f9c280c4100cbf3b7cb77d4"
]
}
]
root@iZj6cabd0bkfnfa0be1b24Z:~#
查看 index.json
tar -xOf tmp.tar index.json | jq
root@iZj6cabd0bkfnfa0be1b24Z:~# tar -xOf tmp.tar index.json | jq
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:20eff0386283951be6c494e3f82030dec06ff14d39da8aff7d001d3d6620ba85",
"size": 1609,
"annotations": {
"containerd.io/distribution.source.docker.io": "sonatype/nexus3",
"io.containerd.image.name": "docker.io/sonatype/nexus3:3.93.1",
"org.opencontainers.image.ref.name": "3.93.1"
}
}
]
}
root@iZj6cabd0bkfnfa0be1b24Z:~#
查看 oci-layout
tar -xOf tmp.tar oci-layout | jq
root@iZj6cabd0bkfnfa0be1b24Z:~# tar -xOf tmp.tar oci-layout | jq
{
"imageLayoutVersion": "1.0.0"
}
root@iZj6cabd0bkfnfa0be1b24Z:~#
查看 os/architecture
tar -xOf tmp.tar $(tar -xOf tmp.tar manifest.json | jq -r '.[0].Config') | jq '{os, architecture}'
root@iZj6cabd0bkfnfa0be1b24Z:~# tar -xOf tmp.tar $(tar -xOf tmp.tar manifest.json | jq -r '.[0].Config') | jq '{os, architecture}'
{
"os": "linux",
"architecture": "amd64"
}
root@iZj6cabd0bkfnfa0be1b24Z:~#
查看 Config
tar -xOf tmp.tar $(tar -xOf tmp.tar manifest.json | jq -r '.[0].Config') | jq
root@iZj6cabd0bkfnfa0be1b24Z:~# tar -xOf tmp.tar $(tar -xOf tmp.tar manifest.json | jq -r '.[0].Config') | jq
{
"architecture": "amd64",
"config": {
"User": "nexus",
"ExposedPorts": {
"8081/tcp": {}
},
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"SONATYPE_DIR=/opt/sonatype",
"NEXUS_HOME=/opt/sonatype/nexus",
"NEXUS_DATA=/nexus-data",
"NEXUS_CONTEXT=",
"SONATYPE_WORK=/opt/sonatype/sonatype-work",
"DOCKER_TYPE=alpine",
"INSTALL4J_ADD_VM_PARAMS=-Djava.util.prefs.userRoot=/nexus-data/javaprefs"
],
"Cmd": [
"/opt/sonatype/nexus/bin/nexus",
"run"
],
"Volumes": {
"/nexus-data": {}
},
"WorkingDir": "/opt/sonatype",
"Labels": {
"com.sonatype.license": "Apache License, Version 2.0",
"com.sonatype.name": "Nexus Repository Manager base image",
"description": "The Nexus Repository Manager server with universal support for popular component formats.",
"io.k8s.description": "The Nexus Repository Manager server with universal support for popular component formats.",
"io.k8s.display-name": "Nexus Repository Manager",
"io.openshift.expose-services": "8081:8081",
"io.openshift.tags": "Sonatype,Nexus,Repository Manager",
"maintainer": "Sonatype <support@sonatype.com>",
"name": "Nexus Repository Manager",
"release": "3.93.1",
"run": "docker run -d --name NAME -p 8081:8081 IMAGE",
"stop": "docker stop NAME",
"summary": "The Nexus Repository Manager server with universal support for popular component formats.",
"url": "https://sonatype.com",
"vendor": "Sonatype",
"version": "3.93.1-04"
},
"ArgsEscaped": true
},
"created": "2026-06-19T18:31:00.669604391Z",
"history": [
{
"created": "2026-06-16T00:01:29.967161902Z",
"created_by": "ADD alpine-minirootfs-3.24.1-x86_64.tar.gz / # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-16T00:01:29.967161902Z",
"created_by": "CMD [\"/bin/sh\"]",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:30:50.587316233Z",
"created_by": "LABEL name=Nexus Repository Manager maintainer=Sonatype <support@sonatype.com> vendor=Sonatype version=3.93.1-04 release=3.93.1 url=https://sonatype.com summary=The Nexus Repository Manager server with universal support for popular component formats. description=The Nexus Repository Manager server with universal support for popular component formats. run=docker run -d --name NAME -p 8081:8081 IMAGE stop=docker stop NAME com.sonatype.license=Apache License, Version 2.0 com.sonatype.name=Nexus Repository Manager base image io.k8s.description=The Nexus Repository Manager server with universal support for popular component formats. io.k8s.display-name=Nexus Repository Manager io.openshift.expose-services=8081:8081 io.openshift.tags=Sonatype,Nexus,Repository Manager",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:30:50.587316233Z",
"created_by": "ARG NEXUS_VERSION=3.93.1-04",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:30:50.587316233Z",
"created_by": "ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/sonatype-nexus-repository-3.93.1-04-assembly.zip",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:30:50.587316233Z",
"created_by": "ARG NEXUS_DOWNLOAD_SHA256_HASH=b5e06c2512e53d56f4a5dd475ea92deaa495feaa58266062023a55f320ccd399",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:30:50.587316233Z",
"created_by": "ENV SONATYPE_DIR=/opt/sonatype",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:30:50.587316233Z",
"created_by": "ENV NEXUS_HOME=/opt/sonatype/nexus NEXUS_DATA=/nexus-data NEXUS_CONTEXT= SONATYPE_WORK=/opt/sonatype/sonatype-work DOCKER_TYPE=alpine",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:30:50.587316233Z",
"created_by": "RUN |3 NEXUS_VERSION=3.93.1-04 NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/sonatype-nexus-repository-3.93.1-04-assembly.zip NEXUS_DOWNLOAD_SHA256_HASH=b5e06c2512e53d56f4a5dd475ea92deaa495feaa58266062023a55f320ccd399 /bin/sh -c apk add openjdk21 tar procps gzip curl shadow && apk cache clean && groupadd --gid 200 -r nexus && useradd --uid 200 -r nexus -g nexus -s /bin/false -d /opt/sonatype/nexus -c 'Nexus Repository Manager user' # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-19T18:30:51.025911243Z",
"created_by": "RUN |3 NEXUS_VERSION=3.93.1-04 NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/sonatype-nexus-repository-3.93.1-04-assembly.zip NEXUS_DOWNLOAD_SHA256_HASH=b5e06c2512e53d56f4a5dd475ea92deaa495feaa58266062023a55f320ccd399 /bin/sh -c apk del --no-cache openssl || true # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-19T18:30:51.876686481Z",
"created_by": "RUN |3 NEXUS_VERSION=3.93.1-04 NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/sonatype-nexus-repository-3.93.1-04-assembly.zip NEXUS_DOWNLOAD_SHA256_HASH=b5e06c2512e53d56f4a5dd475ea92deaa495feaa58266062023a55f320ccd399 /bin/sh -c apk update && apk add --no-cache openssl # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-19T18:30:51.901657233Z",
"created_by": "WORKDIR /opt/sonatype",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-19T18:31:00.255871035Z",
"created_by": "RUN |3 NEXUS_VERSION=3.93.1-04 NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/sonatype-nexus-repository-3.93.1-04-assembly.zip NEXUS_DOWNLOAD_SHA256_HASH=b5e06c2512e53d56f4a5dd475ea92deaa495feaa58266062023a55f320ccd399 /bin/sh -c curl -L ${NEXUS_DOWNLOAD_URL} --output sonatype-nexus-repository-${NEXUS_VERSION}-assembly.zip && echo \"${NEXUS_DOWNLOAD_SHA256_HASH} sonatype-nexus-repository-${NEXUS_VERSION}-assembly.zip\" > sonatype-nexus-repository-${NEXUS_VERSION}-assembly.zip.sha256 && sha256sum -c sonatype-nexus-repository-${NEXUS_VERSION}-assembly.zip.sha256 && unzip sonatype-nexus-repository-${NEXUS_VERSION}-assembly.zip && rm -f sonatype-nexus-repository-${NEXUS_VERSION}-assembly.zip sonatype-nexus-repository-${NEXUS_VERSION}-assembly.zip.sha256 && mv nexus-${NEXUS_VERSION} $NEXUS_HOME && chown -R nexus:nexus ${SONATYPE_WORK} && mv ${SONATYPE_WORK}/nexus3 ${NEXUS_DATA} && ln -s ${NEXUS_DATA} ${SONATYPE_WORK}/nexus3 # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-19T18:31:00.328587624Z",
"created_by": "RUN |3 NEXUS_VERSION=3.93.1-04 NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/sonatype-nexus-repository-3.93.1-04-assembly.zip NEXUS_DOWNLOAD_SHA256_HASH=b5e06c2512e53d56f4a5dd475ea92deaa495feaa58266062023a55f320ccd399 /bin/sh -c echo \"#!/bin/bash\" >> ${SONATYPE_DIR}/start-nexus-repository-manager.sh && echo \"cd /opt/sonatype/nexus\" >> ${SONATYPE_DIR}/start-nexus-repository-manager.sh && echo \"exec ./bin/nexus run\" >> ${SONATYPE_DIR}/start-nexus-repository-manager.sh && chmod a+x ${SONATYPE_DIR}/start-nexus-repository-manager.sh && chmod a+x ${SONATYPE_DIR}/nexus/bin/nexus && sed -e '/^nexus-context/ s:$:${NEXUS_CONTEXT}:' -i ${NEXUS_HOME}/etc/nexus-default.properties # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-19T18:31:00.669604391Z",
"created_by": "RUN |3 NEXUS_VERSION=3.93.1-04 NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/sonatype-nexus-repository-3.93.1-04-assembly.zip NEXUS_DOWNLOAD_SHA256_HASH=b5e06c2512e53d56f4a5dd475ea92deaa495feaa58266062023a55f320ccd399 /bin/sh -c apk del gzip shadow # buildkit",
"comment": "buildkit.dockerfile.v0"
},
{
"created": "2026-06-19T18:31:00.669604391Z",
"created_by": "VOLUME [/nexus-data]",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:31:00.669604391Z",
"created_by": "EXPOSE [8081/tcp]",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:31:00.669604391Z",
"created_by": "USER nexus",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:31:00.669604391Z",
"created_by": "ENV INSTALL4J_ADD_VM_PARAMS=-Djava.util.prefs.userRoot=/nexus-data/javaprefs",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
},
{
"created": "2026-06-19T18:31:00.669604391Z",
"created_by": "CMD [\"/opt/sonatype/nexus/bin/nexus\" \"run\"]",
"comment": "buildkit.dockerfile.v0",
"empty_layer": true
}
],
"os": "linux",
"rootfs": {
"type": "layers",
"diff_ids": [
"sha256:34884abbe92863fce933ed7c39c0e045631af0ed86d5cc0dfbdf9fdca426ce3c",
"sha256:df023aa597b33b38b46c01eb89eeaba7d45d571fe5f8ebf488190f051dfa0ec4",
"sha256:b842fd4417d6a7e8259ed56c07c71658161cfd0c7e9623055b534ddda447e4dd",
"sha256:3458390a7cdc5b9634a62251c5cda5a102fe24664691e7ddf88780fef8884b73",
"sha256:6b80e7f47801b89851b784f3e108890eeccde9bf71ec634654561b38c8e9bcaa",
"sha256:7a7531e8daa307d9d6340458489740fa43c67e9a8257cb948ed88e9dcd5a1c07",
"sha256:813a69f645df221899815ff91edf19f4b23ca45456a130f43a7eaa1f4bb91f87",
"sha256:7c80824afa5a0ea22975cd5c2ffefee5fde038e23d894bcbfa671f13ded2112d"
]
}
}
root@iZj6cabd0bkfnfa0be1b24Z:~#