도커 Docker 이미지 명령
search, pull, rmi, save, load
# 키워드로 도커허브에서 이미지 검색
# OFFICIAL 이미지는 도커 허브에서 관리
vagrant@docker:~$ docker search httpd
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
httpd The Apache HTTP Server Project 3566 [OK]
centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or bui… 40
도커허브계정/이미지명 설명 별점 자동화빌드 기능
-> 보통은 dockerhub 가서 검색
# 이미지 확인
vagrant@docker:~$ docker images
#docker image ls 와 같은 명령어
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest 30287d899656 7 days ago 138MB
ubuntu latest 9873176a8ff5 13 days ago 72.7MB
hello-world latest d1165f221234 3 months ago 13.3kB
# docker pull
# 이미지를 실행하지 않고 받기만 한다
vagrant@docker:~$ docker pull centos
# docker pull docker.io/library/centos:latest 뒤에 생략 된 것
Using default tag: latest
latest: Pulling from library/centos
7a0437f04f83: Pull complete
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
# 해시를 비교해서 이상없으면 다운로드 완료
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
# 같은 명령어
vagrant@docker:~$ docker image pull httpd
vagrant@docker:~$ docker pull httpd
vagrant@docker:~$ docker image pull httpd
vagrant@docker:~$ docker pull httpd
# 태그 지정하여 pulling
# 태그 지정 => 버전, 아키텍쳐(x86,amd64)
# 이미지를 사용할 때 특정 버전이나 아키텍쳐의 태그를 지정해야 한다 (latest사용 x)
vagrant@docker:~$ docker pull mysql:5.7
: 5.7 버전
# 같은 이미지에 여러개의 태그를 붙일 수 있다
vagrant@docker:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 09361feeb475 7 days ago 447MB
mysql 8 5c62e459e087 7 days ago 556MB
mysql latest 5c62e459e087 7 days ago 556MB
-> 8과 latest는 같은 이미지
# 이미지 확인
vagrant@docker:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 09361feeb475 7 days ago 447MB
mysql 8 5c62e459e087 7 days ago 556MB
mysql latest 5c62e459e087 7 days ago 556MB
httpd latest 30287d899656 7 days ago 138MB
ubuntu latest 9873176a8ff5 13 days ago 72.7MB
hello-world latest d1165f221234 3 months ago 13.3kB
centos latest 300e315adb2f 6 months ago 209MB
# 이미지 삭제
vagrant@docker:~$ docker image rm mysql
vagrant@docker:~$ docker rmi mysql:8
vagrant@docker:~$ docker rmi 09361feeb475
# IMAGE ID 앞에 두글자(09)만 써도 삭제된다
# 재확인
vagrant@docker:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest 30287d899656 7 days ago 138MB
ubuntu latest 9873176a8ff5 13 days ago 72.7MB
hello-world latest d1165f221234 3 months ago 13.3kB
centos latest 300e315adb2f 6 months ago 209MB
-> mysql:latest 와 mysql:8 , mysql:5.7 이미지가 삭제된것을 확인
# 로컬에 있는 이미지를 파일(httpd.tar)에 저장
vagrant@docker:~$ docker save -o httpd.tar httpd
vagrant@docker:~$ ls
httpd.tar
# 이미지 받기
개인이 만든 이미지를 save해서 다른사람에게 파일을주고 다른 사람이 load
vagrant@docker:~$ docker load -i httpd.tar
Loaded image: httpd:latest