Skip to Content
Suffering builds character
아카이브25.devopsDocker특징2.이미지 관리6.이미지 레이어 공유를 통한 용량 최적화

6.이미지 레이어 공유를 통한 용량 최적화

1. 도커 이미지 레이어의 레이어 공유

1-1. diamol/node 이미지 받아오기

terminal
docker pull diamol/node

해당 이미지의 용량 조회

terminal
docker images

실행 결과

terminal
REPOSITORY TAG IMAGE ID CREATED SIZE diamol/node latest 9dfa73010b19 4 years ago 75.3MB

SIZE 부분을 보면 약 75MB를 사용하고 있음을 확인할 수 있음

1-2. diamol/node 이미지로 구성된 다른 이미지 생성 및 실행 -1

아래 경로로 이동

terminal
cd ~/080258/ch02/exercises/hello-diamol-web

dockerfile에서 diamol/node이미지를 사용 중인 것 확인하기

terminal
cat dockerfile

실행 결과

Dockerfile
FROM diamol/apache COPY html/ /usr/local/apache2/htdocs/

이미지 빌드

terminal
docker build -t hello-web .

이미지 용량 조회

terminal
docker images

실행 결과

terminal
REPOSITORY TAG IMAGE ID CREATED SIZE hello-web latest f2a4c8d23c26 9 minutes ago 55.5MB diamol/node latest 9dfa73010b19 4 years ago 75.3MB

hello-web은 55MB 정도를 차지하고 있음

1-3. diamol/node 이미지로 구성된 다른 이미지 생성 및 실행 -2

아래 경로로 이동

terminal
cd ~/080258/ch03/exercises/web-ping

이미지 빌드

terminal
docker build --tag web-ping .

이미지 용량 조회

terminal
docker images

실행 결과

terminal
REPOSITORY TAG IMAGE ID CREATED SIZE hello-web latest f2a4c8d23c26 12 minutes ago 55.5MB web-ping latest 6c1534d25633 34 minutes ago 75.3MB diamol/node latest 9dfa73010b19 4 years ago 75.3MB

docker images 명령어를 통해 조회된 이미지 사용 용량은 약 205MB를 사용하는 것처럼 보이지만, 이는 실제 용량이 아닌 논리적인 개념으로 표현된 용량이라고 볼 수 있음

1-4. 전체 이미지의 실제 사용 용량 조회

docker system df 명령어를 통해 이미지가 실제 디스크에서 차지하는 용량 조회

terminal
docker system df
terminal
Images 2 0 130.8MB 130.8MB (100%) Containers 0 0 0B 0B Local Volumes 0 0 0B 0B Build Cache 18 0 1.314kB 1.314kB

실제 이미지 사용 용량은 (55+75+75 = 205MB)가 아닌 130MB 정도를 사용하고 있음

Last updated on