Development/Docker
[Docker] Docker Private Registry 사용하기
sanggeun.choi
2023. 1. 15. 17:27
반응형
Docker Registry 실행
Docker Registry를 실행할 서버에서 아래 작업을 수행
해당 예제에서 Docker Registry 서버 주소는 192.168.56.11
vi docker-compose.yml
version: "3.3"
volumes:
registry_data: { }
services:
registry:
image: registry
container_name: registry
volumes:
- registry_data:/var/lib/registry/docker/registry/v2 # image 저장
ports:
- "5000:5000"
위 내용 저장 후 아래 명령어로 실행
docker-compose up -d
daemon.json 설정
Docker Registry에 접근할 서버에 해당 설정을 해주지 않으면 push/pull 명령어 수행시 "server gave HTTP response to HTTPS client" 오류가 발생
Linux 경로 : /etc/docker/daemon.json
Windows, Mac 경로 : ~/.docker/daemon.json
아래 내용 추가 후 Docker 재실행
{
...
"insecure-registries": [
"192.168.56.11:5000"
]
}
Docker 이미지 빌드
vi Dockerfile
FROM ubuntu:latest
CMD echo 'Hello, new world!'
위 내용 저장 후 아래 명령어로 빌드
docker build -t 192.168.56.11:5000/example .
빌드 완료되면 아래 명령어로 이미지 확인
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.56.11:5000/example latest a4e72b1a4cc9 5 weeks ago 77.8MB
Docker Registry로 Push
아래 명령어로 push
docker image push 192.168.56.11:5000/example
Docker Registry에 push 성공했으면 아래 링크에 접속하여 확인 할 수 있다.
curl http://192.168.56.11:5000/v2/_catalog
{"repositories":["example"]}
curl http://192.168.56.11:5000/v2/example/tags/list
{"name":"example","tags":["latest"]}
Docker Registry로부터 Pull
현재 로컬 PC에 192.168.56.11:5000/example 이미지가 존재하기 때문에 Pull 테스트를 위해 아래 명령어로 이미지 삭제
docker image rm -f 192.168.56.11:5000/example
아래 명령어로 이미지 pull
docker pull 192.168.56.11:5000/example
pull 성공 했으면 아래 명령어로 확인할 수 있다.
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.56.11:5000/example latest a4e72b1a4cc9 5 weeks ago 77.8MB
참고
반응형