반응형

 

Docker 개인 저장소 구축하기

 

보통은 알려진 CA에서 발급한 TLS 인증서를 사용하여 레지스트리를 보호하는 것이 매우 권장되지만, 자체 서명된 인증서를 사용하거나 암호화되지 않은 HTTP 연결을 통해 레지스트리를 사용하도록 선택할 수 있습니다. 만약 인터넷이 안되거나 그냥 개인이 따로 저장하겠다고하면 HTTP 연결을 통해 개인 저장소를 구축할 수 있습니다.

 

Docker 명령은 기본적으로 Docker Hub를 사용합니다. 

Docker 저장소 서버는 Docker registry 서버라고 부릅니다.

# docker push 명령으로 레지스트리 서버에 이미지를 올리고,

# docker pull 명령으로 이미지를 받을 수 있습니다.

 

 

 

insecure-registry 설정

# vi /etc/docker/daemon.json

{
  "insecure-registries" : ["192.168.0:201:5000"]
}

# systemctl restart docker
  • daemon.json 생성 및 해당 내용 저장
  • docker restart

 

 

 

개인 저장소가 잘 구축 되었는지 ubuntu 서버 2개로 테스트 해봤습니다.

 

 

개인저장소 구축한 서버

# docker run -d -p 5000:5000 --name hello-registry \
> -v /tmp/registry:/tmp/registry \
> registry
2976da0da8d746a1ba60f88930dd46bff8143795c516dd9653fcf1a6942432e5
#
# docker ps 
CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS          PORTS                                       NAMES
2976da0da8d7   registry            "/entrypoint.sh /etc…"   3 seconds ago    Up 2 seconds    0.0.0.0:5000->5000/tcp, :::5000->5000/tcp   hello-registry
  • 이미지 파일은 호스트의 /tmp/registry 디렉터리에 저장됩니다.

 

 

 

이미지 tag, push 설정하기

# docker build --tag hello:0.1 .

# docker images
REPOSITORY                       TAG           IMAGE ID       CREATED          SIZE
hello                            0.1           75f0625417ad   36 seconds ago   232MB

# docker tag hello:0.1 localhost:5000/hello:0.1

# docker images
REPOSITORY                       TAG           IMAGE ID       CREATED              SIZE
hello                            0.1           75f0625417ad   About a minute ago   232MB
localhost:5000/hello             0.1           75f0625417ad   About a minute ago   232MB

# docker push localhost:5000/hello:0.1
The push refers to repository [localhost:5000/hello]
2d1630f34efb: Pushed 
0492b535da40: Pushed 
1db69eba3ab3: Pushed 
b9b64cd744c9: Pushed 
83109fa660b2: Pushed 
30d3c4334a23: Pushed 
f2fa9f4cf8fd: Pushed 
0.1: digest: sha256:6b8296113e568e6184eb893fd02f006034c26b0778c86922cd65554f0f379106 size: 1782
  • 가지고있는 Dockerfile을 build 하여 name : hello | tag : 0.1로 image 생성
  • tag 생성 : docker tag <이미지이름>:<tag> <registry URL>/<이미지 이름>:<tag>
  • push 명령 : docker push <registry URL>/<이미지 이름>:<tag>

 

 

 

개인저장소에 있는 이미지를 Pull 받을 서버

# docker pull 192.168.0.201:5000/hello:0.1
Error response from daemon: Get "https://192.168.0.201:5000/v2/": http: server gave HTTP response to HTTPS client
  • pull 명령으로 개인저장소 서버에서 이미지를 받아오는데 오류 로그 발생
  • 해결방법 : insecure-registries 설정 필요

 

 

# vi /etc/docker/daemon.json
{
          "insecure-registries" : ["192.168.0.201:5000"]
}

# docker pull 192.168.0.201:5000/hello:0.1
0.1: Pulling from hello
2e6e20c8e2e6: Pull complete 
0551a797c01d: Pull complete 
512123a864da: Pull complete 
0cde67eab025: Pull complete 
119857f951bc: Pull complete 
41786f85cd57: Pull complete 
56705ad25a7d: Pull complete 
Digest: sha256:6b8296113e568e6184eb893fd02f006034c26b0778c86922cd65554f0f379106
Status: Downloaded newer image for 192.168.0.201:5000/hello:0.1
192.168.0.201:5000/hello:0.1

# docker images
REPOSITORY                 TAG       IMAGE ID       CREATED          SIZE
192.168.0.201:5000/hello   0.1       75f0625417ad   14 minutes ago   232MB
  • insecure-registries 설정 후 pull 했을때 이미지 받아오기 완료

 

 

 

참고링크 : https://docs.docker.com/registry/insecure/

 

 

 

 

 

 

 

 

반응형

+ Recent posts