기존: 이미지 1을 지운다 하더라도 이미지 2에서 레이어 A, B, C를 사용하고 있기 때문에 지워지지 않음
레이어 개념 도입: 이미 존재하는 레이어 A, B는 새로 다운로드 받을 필요가 없음
sudo docker pull nginx
sudo docker inspect nginx
sudo docker info
sudo -i
cd /var/lib/docker/overlay2
root@server1-VirtualBox:/var/lib/docker/overlay2# ls
0cc29ea5605872d9c8291673064e85b07160203fbf04b34eeeed899731361960 # 레이어 변경 사항 저장
615767e7221dbc99b8e441e35a88df5d74c911f2674ceaa28001388535e95be2 # 레이어 변경 사항 저장
9f3bb671f38d7f61f661af369d420cdedb195e4d623bdb6ba8e3b045f72e8d69 # 레이어 변경 사항 저장
l # 원본 레이어 저장
du -sh /var/lib/docker/ #도커가 설치된 환경 용량 확인
2.0G /var/lib/docker/
du -sh /var/lib/docker/image/ # 도커 이미지에 대한 정보 저장 디렉토리
2.7M /var/lib/docker/image/
du -sh /var/lib/docker/overlay2/ # 도커 이미지의 파일 시스템이 사용되는 실제 디렉토리
2.0G /var/lib/docker/overlay2/
du -sh /var/lib/docker/containers/ # 도커 컨테이너 정보 저장 디렉토리
136K /var/lib/docker/containers
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version:
runc version:
init version:
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.18.0-20-generic
Operating System: Ubuntu 18.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.852GiB
Name: server1-VirtualBox
ID: 637E:FYG4:SFQN:R3UE:I47D:2FPI:XXKP:PB2R:C6VG:GPFA:KWDY:VDNG
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: <https://index.docker.io/v1/>
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
root@server1-VirtualBox:~# clear
root@server1-VirtualBox:~# cd /var/lib/docker/
root@server1-VirtualBox:/var/lib/docker# ls
buildkit containers image network overlay2 plugins runtimes swarm tmp trust volumes
root@server1-VirtualBox:/var/lib/docker# du -sh image/
3.0M image/
root@server1-VirtualBox:/var/lib/docker# du -sh overlay2/
1.8G overlay2/
root@server1-VirtualBox:/var/lib/docker# du -sh containers/
56K containers/
root@server1-VirtualBox:/var/lib/docker# docker image
Usage: docker image COMMAND
Manage images
Commands:
build Build an image from a Dockerfile
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Display detailed information on one or more images
load Load an image from a tar archive or STDIN
ls List images
prune Remove unused images
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rm Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
Run 'docker image COMMAND --help' for more information on a command.
root@server1-VirtualBox:/var/lib/docker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 5c62e459e087 3 weeks ago 556MB
consol/tomcat-7.0 latest 7c34bafd1150 6 years ago 601MB
root@server1-VirtualBox:/var/lib/docker# docker image
sudo docker run -d --name tc -p 80:8080 tomcat
firefox 127.0.0.1:80
sudo docker exec -it tc /bin/bash