본문 바로가기
Docker/실습

[Docker-실습] 5.Container Registry

by Haengsin 2021. 8. 23.

1. Public Repository(hub.docker.com) 에 컨테이너 업로드 및 다운로드

$ docker login

( /root/.docker/config.json. 에 login 정보 저장됨)

(1) 이미지 검색

$ docker search [이미지명]:[태그]

$ docker search httpd:latest

: hub.docker.com 에서 컨테이너 이미지 검색.

(2) 이미지 다운로드

$ docker pull [이미지명]:[태그]

$ docker pull httpd:latest

(3) 이미지 확인

$ docker images

 

(4) docker hub에 Repository에 업로드

다운 받은 이미지의 개인 Repository에 Push하기 위해서는 이미지의 tag를 바꿔주어야 한다.

$ docker tag [컨테이너 이름]:[태그]  [계정이름]/[컨테이너 이름]:[태그]

$ docker tag httpd:latest metalk2003/httpd:latest

 

 

$ docker push [계정이름]/[컨테이너 이름]:[태그]

$ docker push metalk2003/httpd:latest

 

2. Private Repository 운영

내 시스템에 컨테이너 저장소를 구축하고 운영하기.

 

※ 현재 서버의 호스트 네임 확인

$ hostname

 

 

[설치]

(1) Docker Hub 에서 최신 registry 이미지를 실행(run)

 

$ docker run -d -p 5000:5000 --restart always --name registry registry:2

 

 

(2) 실행 확인

$ docker ps 

 

[운영]

이전에 다운로드 받은 httpd 이미지 파일을 설치한 Registry 컨테이너에 업로드

(1) 대상 이미지 확인

$ docker images httpd 

$ docker tag httpd:latest localhost:5000/httpd:latest

$ docker images localhost:5000/httpd

$ docker push localhost:5000/httpd:latest

 

docker registry는 Container 실행 시, /var/lib/docker/volumes/~/_data/ 아래 data가 쌓인다.  아래와 같이 실행한 컨테이너의 UUID에 대한 경로를 타고 들어가면 httpd 가 있는 것을 확인할 수 있다.

ls -al /var/lib/docker/volumes/988b78a8206e967cb009a6090527ed75a47409a9555d28e0bfb69c93a35fa9c4/_data/docker/registry/v2/repositories/

 

※ 이성미, [따배도] 도커 시리즈 ,TTABAE-LEARN, https://www.youtube.com/watch?v=bQ6XxI0Ep_Q&list=PLApuRlvrZKogb78kKq1wRvrjg1VMwYrvi&index=14, 2021-08-31