코드코코

[Docker] [도커 기본 개념] [실습] docker registry - 컨테이너 보관창고 본문

기록/Docker

[Docker] [도커 기본 개념] [실습] docker registry - 컨테이너 보관창고

코드코코 2022. 6. 4. 22:42

Docker Registry

- 여러 형태의 컨테이너 이미지가 모여있는 공간

- 권한에 따라

   public : dockerHub

   private : registry 컨테이너를 이용

$ docker run -d -p 5000:5000 --restart always --name registry registry:2
  • dockerHost이름:포트넘버/컨테이너이미지       ex) localhost:5000/ubuntu:18.04

 

[실습1] hub.docker.come 에 컨테이너 업로드 및 다운로드

 

1. 도커 허브에서 httpd 컨테이너 검색

$ docker seach httpd

-official : 도커허브에서 직접제공

[guru@docker-centos ~]$ docker search httpd
NAME                                    DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
httpd                                   The Apache HTTP Server Project                  4029      [OK]       
centos/httpd-24-centos7                 Platform for running Apache httpd 2.4 or bui…   44                   
centos/httpd                                                                            35                   [OK]
hypoport/httpd-cgi                      httpd-cgi                                       2                    [OK]
solsson/httpd-openidc                   mod_auth_openidc on official httpd image, ve…   2                    [OK]
dockerpinata/httpd                                                                      1                    
nnasaki/httpd-ssi                       SSI enabled Apache 2.4 on Alpine Linux          1                    
centos/httpd-24-centos8                                                                 1                    
jonathanheilmann/httpd-alpine-rewrite   httpd:alpine with enabled mod_rewrite           1                    [OK]
inanimate/httpd-ssl                     A play container with httpd, ssl enabled, an…   1                    [OK]
manageiq/httpd                          Container with httpd, built on CentOS for Ma…   1                    [OK]
dariko/httpd-rproxy-ldap                Apache httpd reverse proxy with LDAP authent…   1                    [OK]
clearlinux/httpd                        httpd HyperText Transfer Protocol (HTTP) ser…   1                    
publici/httpd                           httpd:latest                                    1                    [OK]
httpdocker/kubia                                                                        0                    
patrickha/httpd-err                                                                     0                    
manageiq/httpd_configmap_generator      Httpd Configmap Generator                       0                    [OK]
e2eteam/httpd                                                                           0                    
amd64/httpd                             The Apache HTTP Server Project                  0                    
paketobuildpacks/httpd                                                                  0                    
manasip/httpd                                                                           0                    
9af925e7043/httpd                                                                       0                    
sandeep1988/httpd-new                   httpd-new                                       0                    
19022021/httpd-connection_test          This httpd image will test the connectivity …   0                    
httpdss/archerysec                      ArcherySec repository                           0                    [OK]

 

2. 이미지 다운 받기

$ docker pull httpd:latest

[guru@docker-centos ~]$ docker pull httpd:latest
latest: Pulling from library/httpd
42c077c10790: Pull complete 
77a357ba66a8: Pull complete 
c56c780a8904: Pull complete 
90bcc5e941a7: Pull complete 
571750298b32: Pull complete 
Digest: sha256:c479bec894c5a7f8878b28e52d03cc95b1e784612ecd01ac7c7394fc5fa2e6e2
Status: Downloaded newer image for httpd:latest
docker.io/library/httpd:latest

 

3. 다운 받은 이미지 확인

$ docker images

[guru@docker-centos ~]$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
httpd        latest    98f93cd0ec3b   7 days ago   144MB

 

4. 도커 로그인 

$ docker login

- 별도로 로그아웃 전 까지는 /home/guru/.docker/config.json 에 로그인 정보가 저장됨

[guru@docker-centos ~]$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: isawmy
Password: 
WARNING! Your password will be stored unencrypted in /home/guru/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

 

5. 레퍼지토리 사용을 위해 이미지 이름 변경

$ docker tag httpd:latest isawmy/httpd:latest

[guru@docker-centos ~]$ docker tag httpd:latest isawmy/httpd:latest

 

6. 도커 허브 레퍼지토리에 업로드

$ docker push isawmy/httpd:latest

- 업로드 되면, 누구든지 다운받을 수 있게 됨

[guru@docker-centos ~]$ docker push isawmy/httpd:latest
The push refers to repository [docker.io/isawmy/httpd]
61c1dd0ba4bd: Mounted from library/httpd 
b83b02d70215: Mounted from library/httpd 
4a48959ac654: Mounted from library/httpd 
4e2b986e3da3: Mounted from library/httpd 
ad6562704f37: Mounted from library/httpd 
latest: digest: sha256:a17755a2d2e581779d2ab6b5df6992a754a16503961f6a9d4e908c71c3d46f2d size: 1365

 

7. 도커 허브의 레퍼지토리 에서 확인 가능

 

[실습 2] Private Registry 운영하기

 

https://hub.docker.com/_/registry

 

Registry - Official Image | Docker Hub

We and third parties use cookies or similar technologies ("Cookies") as described below to collect and process personal data, such as your IP address or browser information. You can learn more about how this site uses Cookies by reading our privacy policy

hub.docker.com

 

1. 로컬 레지스트리 실행하기

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

[guru@docker-centos ~]$ docker run -d -p 5000:5000 --restart always --name registry registry:2
Unable to find image 'registry:2' locally
2: Pulling from library/registry
2408cc74d12b: Pull complete 
ea60b727a1ce: Pull complete 
c87369050336: Pull complete 
e69d20d3dd20: Pull complete 
fc30d7061437: Pull complete 
Digest: sha256:bedef0f1d248508fe0a16d2cacea1d2e68e899b2220e2258f1b604e1f327d475
Status: Downloaded newer image for registry:2
435f00e5515759171fa6b40c291a9cfb0951e37a93f28988bd7087e57d1882a2

- 컨테이너 저장소

 

2. 이미지 이름 변경

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

[guru@docker-centos ~]$ docker tag httpd:latest localhost:5000/httpd:latest

 

3. 로컬 레지스트리에 업로드

$ docker push localhost:5000/httpd:latest

- 컨테이너 저장소가 모여있는 위치 : /var/lib/docker/volumes/컨테이너이름uuid/_data/docker/registry/v2/repositories

[guru@docker-centos ~]$ docker push localhost:5000/httpd:latest
The push refers to repository [localhost:5000/httpd]
61c1dd0ba4bd: Pushed 
b83b02d70215: Pushed 
4a48959ac654: Pushed 
4e2b986e3da3: Pushed 
ad6562704f37: Pushed 
latest: digest: sha256:a17755a2d2e581779d2ab6b5df6992a754a16503961f6a9d4e908c71c3d46f2d size: 1365