[Docker] 12. 로컬 환경에 Docker 레지스트리 구축

Date:     Updated:

카테고리:

태그:

[Docker] 12. 로컬 환경에 Docker 레지스트리 구축



🔔 로컬 환경에 Docker 레지스트리 구축


(a) registry 검색

$ docker search registry
NAME        DESCRIPTION                                     STARS   OFFICIAL    AUTOMATED
registry    The Docker Registry 2.0 implementation for...   1700    [OK]


(b) registry 다운로드

$ docker image pull registry 
Using default tag: latest
latest: Pulling from library/registry 
81033e7c1d6a: Pull complete
~중략~
Digest: sha256:672d519d7fd7bbc7a448d17956ebeefe225d5eb27509d8dc5ce67ecb4a0bce54
Status: Downloaded newer image for registry: latest


(c) registry 이미지 확인

$ docker image ls registry
REPOSITORY      TAG         IMAGE ID            CREATED         SIZE
registry        latest      d1fd7d86a825        3 weeks ago     33.5MB


(d) registry 컨테이너 시작

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


(e) registry 컨테이너 확인

$ docker container ls
CONTAINER ID    IMAGE       ~중략~  STATUS          PORTS                   NAMES
2a912a0de982    registry    ~중략~  Up 14 seconds   0.0.0.0:5000->5000/tcp  registry


🔔 Docker 이미지 업로드


(1) 예제 Dockerfile 준비

FROM ubuntu:18.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
	&& apt-get install -y apache2 php \
	&& apt-get install -y vim wget locales


(2) Dockerfile 빌드

docker build -t docker-test .


(3) 태그 변경

docker image tag [로컬의 이미지명] [업로드할 레지스트리의 주소 : 포트 번호] / [이미지명]
$ docker image tag docker-test localhost:5000/docker-test

$ docker image ls
REPOSITORY                      TAG         IMAGE ID        ~중략~
docker-test                     latest      186ac198fcdf    ~중략~
localhost:5000/docker-test      latest      186ac198fcdf    ~중략~


(4) 이미지 업로드

$ docker image push localhost:5000/docker-test
The push refers to a repository [localhost:5000/docker-test]
68177698d48b: Preparing
~중략~
sha256:766aca0e61a74781e5cf087943bc7403089f84c8d4dc2b625a40f2884729d5e7 size: 4283


🔔 Docker 이미지 다운로드

(1) 기존 이미지 삭제

$ docker image rm localhost:5000/docker-test
$ docker image rm docker-test


(2) 이미지 다운로드

$ docker image pull localhost:5000/docker-jupyter
Using default tag: latest
latest: Pulling from docker-jupyter
~중략~
Digest: sha256:766aca0e61a74781e5cf087943bc7403089f84c8d4dc2b625a40f2884729d5e7
Status: Downloaded newer image for localhost:5000/docker-jupyter:latest


(3) 이미지 확인

$ docker image ls
REPOSITORY                      TAG         IMAGE ID        ~중략~
localhost:5000/docker-test      latest      186ac198fcdf    ~중략~


🔔 push할 때 에러 메시지가 나오는 경우

# 아래와 같은 오류가 발생 시
Get https://localhost:5000/v2/: http: server gave HTTP response to HTTPS client
# /etc/docker/daemon.json 파일에 다음과 같이 insecure-registries를 추가해준다. 
# (나머지 항목은 무시하고 insecure-registries에 추가해주면 된다.)

{
    "registry-mirrors": [], 
    "insecure-registries": [ 
        "{hostIP}:5000"
    ],
    "debug": true,
    "experimental": false
}


DOCKER 카테고리 내 다른 글 보러가기

댓글 남기기