Skip to content

Instantly share code, notes, and snippets.

@spyoungtech
Last active Oct 3, 2022
Embed
What would you like to do?
Parse docker repo info
from parse_repo import parse
with open('6.0.5.md') as f:
text = f.read()
images = parse(text)
for image in images:
print('Image Digest:', image.digest)
print('Layers:')
for layer in image.layers:
print('\t', "Digest:", layer.digest)
print('\t', "Size:", layer.size)
print('\t', "Last Modified:", layer.modified_date)
import re
from typing import Sequence
from dataclasses import dataclass
import datetime
@dataclass
class Layer:
digest: str
modified_date: datetime.datetime
size: int
mime: str
@dataclass
class Image:
digest: str
layers: Sequence[Layer]
def parse_iter(text):
image_digest_pattern = r'Image ID\:\s+\`(sha256\:[a-f0-9]+)\`'
layers_pattern = r'\s+(\-\s+\`(sha256\:[a-f0-9]+)\`\s+Last Modified\:\s+((?:.*)GMT)\s+Size\:\s+((?:.*)\(?\d+(?:\.\d+)? (?:bytes|B)\)?)\s+MIME:\s+(.*)$)'
layer_parts = text.split('Layers:')[1:]
layer_groups = []
layer_dt_format = '%a, %d %b %Y %H:%M:%S GMT'
for part in layer_parts:
part_layers = []
for layer_group in re.findall(layers_pattern, part):
_, layer_digest, layer_modified_date, size, mime = layer_group
layer_modified_date = datetime.datetime.strptime(layer_modified_date, layer_dt_format)
if ' B' in size:
size_pattern = r'(\d+)\.\d+ B'
else:
size_pattern = r'(?:.*)\((\d+) bytes\)'
size = int(re.match(size_pattern, size).groups()[0])
layer = Layer(digest=layer_digest,
modified_date=layer_modified_date,
size=size,
mime=mime
)
part_layers.append(layer)
layer_groups.append(part_layers)
image_digests = []
for image_digest in re.findall(image_digest_pattern, text):
image_digests.append(image_digest)
assert len(image_digests) == len(layer_groups)
for image_digest, layer_groups in zip(image_digests, layer_groups):
yield Image(digest=image_digest, layers=layer_groups)
def parse(*args, **kwargs):
return list(parse_iter(*args, **kwargs))

couchbase:6.0.5

$ docker pull couchbase@sha256:06e45bbeffdcd7d9cf9150ba928206bec9f23090d2ea60a8eb58b042e3a09bad
  • Manifest MIME: application/vnd.docker.distribution.manifest.list.v2+json
  • Platforms:
    • linux; amd64

couchbase:6.0.5 - linux; amd64

$ docker pull couchbase@sha256:1a3717bde6a97e7436492561f83c7d6bc8cf5ab57ba63dab318d2c54b84883ac
  • Docker Version: 19.03.12
  • Manifest MIME: application/vnd.docker.distribution.manifest.v2+json
  • Total Size: 481.0 MB (481029867 bytes)
    (compressed transfer size, not on-disk size)
  • Image ID: sha256:dc09c2d8224e4b81e0f4a9a12aaea9ca7d8d135f07de7622eda65118c97081ca
  • Entrypoint: ["\/entrypoint.sh"]
  • Default Command: ["couchbase-server"]
# Thu, 21 Jan 2021 03:39:31 GMT
ADD file:925571658dd8453e5c80d862f5791d6b26b3c2a8688937b11741f2f2c5cdbfd7 in / 
# Thu, 21 Jan 2021 03:39:32 GMT
RUN set -xe 		&& echo '#!/bin/sh' > /usr/sbin/policy-rc.d 	&& echo 'exit 101' >> /usr/sbin/policy-rc.d 	&& chmod +x /usr/sbin/policy-rc.d 		&& dpkg-divert --local --rename --add /sbin/initctl 	&& cp -a /usr/sbin/policy-rc.d /sbin/initctl 	&& sed -i 's/^exit.*/exit 0/' /sbin/initctl 		&& echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup 		&& echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean 	&& echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean 	&& echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean 		&& echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages 		&& echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes 		&& echo 'Apt::AutoRemove::SuggestsImportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests
# Thu, 21 Jan 2021 03:39:34 GMT
RUN rm -rf /var/lib/apt/lists/*
# Thu, 21 Jan 2021 03:39:35 GMT
RUN mkdir -p /run/systemd && echo 'docker' > /run/systemd/container
# Thu, 21 Jan 2021 03:39:36 GMT
CMD ["/bin/bash"]
# Fri, 05 Mar 2021 23:21:18 GMT
MAINTAINER Couchbase Docker Team <docker@couchbase.com>
# Fri, 05 Mar 2021 23:24:11 GMT
RUN apt-get update &&     apt-get install -yq runit wget chrpath tzdata     lsof lshw sysstat net-tools numactl python-httplib2 &&     apt-get autoremove && apt-get clean &&     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Fri, 05 Mar 2021 23:24:12 GMT
RUN if [ ! -x /usr/sbin/runsvdir-start ]; then         cp -a /etc/runit/2 /usr/sbin/runsvdir-start;     fi
# Fri, 05 Mar 2021 23:24:13 GMT
ARG CB_VERSION=6.0.5
# Fri, 05 Mar 2021 23:24:13 GMT
ARG CB_RELEASE_URL=https://packages.couchbase.com/releases/6.0.5
# Fri, 05 Mar 2021 23:24:13 GMT
ARG CB_PACKAGE=couchbase-server-enterprise_6.0.5-ubuntu16.04_amd64.deb
# Fri, 05 Mar 2021 23:24:13 GMT
ARG CB_SHA256=3227bd9bf04affeea6c567a9e87cde585d2d49e5548b95204ffbda7dea8d451a
# Fri, 05 Mar 2021 23:24:13 GMT
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/couchbase/bin:/opt/couchbase/bin/tools:/opt/couchbase/bin/install
# Fri, 05 Mar 2021 23:24:14 GMT
# ARGS: CB_PACKAGE=couchbase-server-enterprise_6.0.5-ubuntu16.04_amd64.deb CB_RELEASE_URL=https://packages.couchbase.com/releases/6.0.5 CB_SHA256=3227bd9bf04affeea6c567a9e87cde585d2d49e5548b95204ffbda7dea8d451a CB_VERSION=6.0.5
RUN groupadd -g 1000 couchbase && useradd couchbase -u 1000 -g couchbase -M
# Fri, 05 Mar 2021 23:25:00 GMT
# ARGS: CB_PACKAGE=couchbase-server-enterprise_6.0.5-ubuntu16.04_amd64.deb CB_RELEASE_URL=https://packages.couchbase.com/releases/6.0.5 CB_SHA256=3227bd9bf04affeea6c567a9e87cde585d2d49e5548b95204ffbda7dea8d451a CB_VERSION=6.0.5
RUN export INSTALL_DONT_START_SERVER=1 &&     wget -N --no-verbose $CB_RELEASE_URL/$CB_PACKAGE &&     echo "$CB_SHA256  $CB_PACKAGE" | sha256sum -c - &&     dpkg -i ./$CB_PACKAGE && rm -f ./$CB_PACKAGE
# Fri, 05 Mar 2021 23:25:03 GMT
# ARGS: CB_PACKAGE=couchbase-server-enterprise_6.0.5-ubuntu16.04_amd64.deb CB_RELEASE_URL=https://packages.couchbase.com/releases/6.0.5 CB_SHA256=3227bd9bf04affeea6c567a9e87cde585d2d49e5548b95204ffbda7dea8d451a CB_VERSION=6.0.5
RUN sed -i -e '1 s/$/\/docker/' /opt/couchbase/VARIANT.txt
# Fri, 05 Mar 2021 23:25:03 GMT
COPY file:d6a307209223b2df102f46f07fd186e09fac7114db2c965bb54097d3b4d3b989 in /etc/service/couchbase-server/run 
# Fri, 05 Mar 2021 23:25:04 GMT
# ARGS: CB_PACKAGE=couchbase-server-enterprise_6.0.5-ubuntu16.04_amd64.deb CB_RELEASE_URL=https://packages.couchbase.com/releases/6.0.5 CB_SHA256=3227bd9bf04affeea6c567a9e87cde585d2d49e5548b95204ffbda7dea8d451a CB_VERSION=6.0.5
RUN chown -R couchbase:couchbase /etc/service
# Fri, 05 Mar 2021 23:25:04 GMT
COPY file:1302333e9e56b11ae357341056dee0080efda9457b1ce3de1a1ecb6023e760ae in /usr/local/bin/ 
# Fri, 05 Mar 2021 23:25:05 GMT
# ARGS: CB_PACKAGE=couchbase-server-enterprise_6.0.5-ubuntu16.04_amd64.deb CB_RELEASE_URL=https://packages.couchbase.com/releases/6.0.5 CB_SHA256=3227bd9bf04affeea6c567a9e87cde585d2d49e5548b95204ffbda7dea8d451a CB_VERSION=6.0.5
RUN ln -s dummy.sh /usr/local/bin/iptables-save &&     ln -s dummy.sh /usr/local/bin/lvdisplay &&     ln -s dummy.sh /usr/local/bin/vgdisplay &&     ln -s dummy.sh /usr/local/bin/pvdisplay
# Fri, 05 Mar 2021 23:25:06 GMT
# ARGS: CB_PACKAGE=couchbase-server-enterprise_6.0.5-ubuntu16.04_amd64.deb CB_RELEASE_URL=https://packages.couchbase.com/releases/6.0.5 CB_SHA256=3227bd9bf04affeea6c567a9e87cde585d2d49e5548b95204ffbda7dea8d451a CB_VERSION=6.0.5
RUN chrpath -r '$ORIGIN/../lib' /opt/couchbase/bin/curl
# Fri, 05 Mar 2021 23:25:06 GMT
COPY file:d816a67f62bfba76d2812cefbe92252afa13f3852775c3e68599df7741e90cb7 in / 
# Fri, 05 Mar 2021 23:25:06 GMT
ENTRYPOINT ["/entrypoint.sh"]
# Fri, 05 Mar 2021 23:25:07 GMT
CMD ["couchbase-server"]
# Fri, 05 Mar 2021 23:25:07 GMT
EXPOSE 11207 11210 11211 18091 18092 18093 18094 18095 18096 8091 8092 8093 8094 8095 8096
# Fri, 05 Mar 2021 23:25:07 GMT
VOLUME [/opt/couchbase/var]
  • Layers:
    • sha256:4007a89234b4f56c03e6831dc220550d2e5fba935d9f5f5bcea64857ac4f4888
      Last Modified: Mon, 18 Jan 2021 19:38:08 GMT
      Size: 46.0 MB (45962352 bytes)
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:5dfa26c6b9c9d1ccbcb1eaa65befa376805d9324174ac580ca76fdedc3575f54
      Last Modified: Thu, 21 Jan 2021 03:41:24 GMT
      Size: 852.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:0ba7bf18aa406cb7dc372ac732de222b04d1c824ff1705d8900831c3d1361ff5
      Last Modified: Thu, 21 Jan 2021 03:41:24 GMT
      Size: 527.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:4c6ec688ebe374ea7d89ce967576d221a177ebd2c02ca9f053197f954102e30b
      Last Modified: Thu, 21 Jan 2021 03:41:24 GMT
      Size: 169.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:2719f824c9406c2ba4ab7af5518af78d4ba0bf60c2d0b77f83c66557395226a0
      Last Modified: Sat, 06 Mar 2021 06:49:49 GMT
      Size: 14.3 MB (14298908 bytes)
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:5282a2432b9dd2f926e519027fd4a1a875a770b4c3c287d8ea4d6800a1371c82
      Last Modified: Sat, 06 Mar 2021 06:49:44 GMT
      Size: 2.1 KB (2073 bytes)
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:5a0c00dacd8aca18f2ef6844c891475528bafd02f875d8dd59cc1531796c486d
      Last Modified: Sat, 06 Mar 2021 06:50:28 GMT
      Size: 420.6 MB (420642042 bytes)
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:bbd58857fe9924ac5a2b72527676a8cfb85b75cce13395e07a98d686bd25b2d1
      Last Modified: Sat, 06 Mar 2021 06:49:44 GMT
      Size: 191.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:249de3010e411cf68b5aea4237d2a4787112fee0c59ff8ca5378e3df92f93e11
      Last Modified: Sat, 06 Mar 2021 06:49:44 GMT
      Size: 431.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:f3041b0ab39d30889c4a11cd2173d0d2cce5bb760dad66cfe214e322f2a4cb07
      Last Modified: Sat, 06 Mar 2021 06:49:41 GMT
      Size: 410.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:e804dc3272c285e17800051f647aabc7bc892e29841b5dd27d92a842ff82a8e4
      Last Modified: Sat, 06 Mar 2021 06:49:41 GMT
      Size: 237.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:6a99b5690d2afd38c09f1207aee0e1040c5909ad824bb174de26c97441dce3f3
      Last Modified: Sat, 06 Mar 2021 06:49:41 GMT
      Size: 217.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:31de2e79737365a26fcd25bc3cc4f59ef3a1d4228a868966d1713d79c43f6890
      Last Modified: Sat, 06 Mar 2021 06:49:42 GMT
      Size: 120.6 KB (120601 bytes)
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
    • sha256:a2993b18dff4f3b48a6e1385e4dc0d61952e41f5c143f1950648c200ed2b72dc
      Last Modified: Sat, 06 Mar 2021 06:49:42 GMT
      Size: 857.0 B
      MIME: application/vnd.docker.image.rootfs.diff.tar.gzip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment