각 Docker 이미지에 대한 레이어 및 레이어 크기 찾기
연구 목적으로 공개 Docker 레지스트리 ( https://registry.hub.docker.com/ ) 를 크롤링하고 1) 평균 이미지에있는 레이어 수와 2) 이러한 레이어의 크기를 확인하여 배포에 대한 아이디어.
그러나 API 및 공용 라이브러리와 github에 대한 세부 정보를 연구했지만 다음과 같은 방법을 찾을 수 없습니다.
- 모든 공개 저장소 / 이미지를 검색합니다 (수천 개라도 반복하려면 시작 목록이 필요합니다)
- 이미지의 모든 레이어 찾기
- 레이어의 크기를 찾으십시오 (이미지가 아니라 개별 레이어의 경우).
누구든지이 정보를 검색하는 방법을 찾도록 도와 줄 수 있습니까?
감사합니다!
편집 : Docker 레지스트리에서 '*'를 검색하면 어디서나 '*'를 언급하는 항목뿐만 아니라 모든 저장소가 반환되는지 확인할 수 있습니까? https://registry.hub.docker.com/search?q=*
/ var / lib / docker / aufs / layers 폴더에서 이미지의 레이어를 찾을 수 있습니다. 스토리지 드라이버를 aufs로 구성한 경우 제공 (기본 옵션)
예:
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0ca502fa6aae ubuntu "/bin/bash" 44 minutes ago Exited (0) 44 seconds ago DockerTest
이제 이미지 "Ubuntu"로 생성 된 컨테이너의 레이어를 봅니다. / var / lib / docker / aufs / layers 디렉토리로 이동하여 파일이 컨테이너 ID로 시작합니다 (여기서는 0ca502fa6aae *).
root@viswesn-vm2:/var/lib/docker/aufs/layers# cat 0ca502fa6aaefc89f690736609b54b2f0fdebfe8452902ca383020e3b0d266f9-init
d2a0ecffe6fa4ef3de9646a75cc629bbd9da7eead7f767cb810f9808d6b3ecb6
29460ac934423a55802fcad24856827050697b4a9f33550bd93c82762fb6db8f
b670fb0c7ecd3d2c401fbfd1fa4d7a872fbada0a4b8c2516d0be18911c6b25d6
83e4dde6b9cfddf46b75a07ec8d65ad87a748b98cf27de7d5b3298c1f3455ae4
이것은 실행하여 같은 결과를 보여줍니다
root@viswesn-vm2:/var/lib/docker/aufs/layers# docker history ubuntu
IMAGE CREATED CREATED BY SIZE COMMENT
d2a0ecffe6fa 13 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
29460ac93442 13 days ago /bin/sh -c sed -i 's/^#\s*\ (deb.*universe\)$/ 1.895 kB
b670fb0c7ecd 13 days ago /bin/sh -c echo '#!/bin/sh' > /usr/sbin/polic 194.5 kB
83e4dde6b9cf 13 days ago /bin/sh -c #(nop) ADD file:c8f078961a543cdefa 188.2 MB
전체 레이어 ID를 보려면 history 명령의 일부로 --no-trunc 옵션으로 실행합니다.
docker history --no-trunc ubuntu
먼저 이미지 ID를 찾을 수 있습니다.
$ docker images -a
그런 다음 레이어와 크기를 찾으십시오.
$ docker history --no-trunc <Image ID>
참고 : Docker 버전 1.13.1을 사용하고 있습니다.
$ docker -v
Docker version 1.13.1, build 092cba3
제 생각 docker history <image>
에는 충분합니다. 이것은 각 레이어의 크기를 반환합니다.
$ docker history jenkinsci-jnlp-slave:2019-1-9c
IMAGE CREATED CREATED BY SIZE COMMENT
93f48953d298 42 min ago /bin/sh -c #(nop) USER jenkins 0B
6305b07d4650 42 min ago /bin/sh -c chown jenkins:jenkins -R /home/je… 1.45GB
https://stackoverflow.com/a/32455275/165865에 아주 좋은 대답이 있습니다.
이미지 아래에서 실행하십시오.
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz images -t
그러면 도커 이미지를 검사하고 레이어를 인쇄합니다.
$ docker image inspect nginx -f '{{.RootFS.Layers}}'
[sha256:d626a8ad97a1f9c1f2c4db3814751ada64f60aed927764a3f994fcd88363b659 sha256:82b81d779f8352b20e52295afc6d0eab7e61c0ec7af96d85b8cda7800285d97d sha256:7ab428981537aa7d0c79bc1acbf208c71e57d9678f7deca4267cc03fba26b9c8]
golang으로 작성된 다이빙을 확인하십시오 .
멋진 도구입니다.
표시되는 모든 정보를 json
파일 로 내보내도록 소스 코드를 조정할 수 있습니다 .
https://hub.docker.com/search?q=* 는 전체 Docker 허브의 모든 이미지를 표시합니다. 와일드 카드를 허용하지 않으므로 검색 명령을 통해 가져올 수 없습니다.
v1.10부터는 이미지를 당기고 다음 명령을 사용하여 이미지의 모든 레이어를 찾을 수 있습니다.
docker pull ubuntu ID=$(sudo docker inspect -f {{.Id}} ubuntu) jq .rootfs.diff_ids /var/lib/docker/image/aufs/imagedb/content/$(echo $ID|tr ':' '/')
3) The size can be found in /var/lib/docker/image/aufs/layerdb/sha256/{LAYERID}/size
although LAYERID != the diff_ids found with the previous command. For this you need to look at /var/lib/docker/image/aufs/layerdb/sha256/{LAYERID}/diff
and compare with the previous command output to properly match the correct diff_id and size.
one more tool : https://github.com/CenturyLinkLabs/dockerfile-from-image
GUI using ImageLayers.io
I've solved this problem by using the search function on Docker's website where '*' is a valid search that returns 200k repositories and then I crawled each invididual page. HTML parsing allows me to extract all the image names on each page.
'Development Tip' 카테고리의 다른 글
ImportError : mock이라는 모듈이 없습니다. (0) | 2020.11.01 |
---|---|
HttpClient 요청에서 IOException 발생 (0) | 2020.11.01 |
uWSGI의 요점은 무엇입니까? (0) | 2020.11.01 |
텍스트 필드에 초기 값을 어떻게 제공합니까? (0) | 2020.11.01 |
SwiftUI는 iOS 12.x 및 이전 버전과 역 호환됩니까? (0) | 2020.11.01 |