1.컨테이너 보관창고가 있어요 ?
Registry: 컨테이너 이미지를 저장하는 저장소
Docker Hub:hub.docker.com
private Registry: 사내의 컨테이너 저장소
2.docker hub(registry)를 사용하고 싶어요.
image 종류: offical images, Verified Publisher,etc
이미지검색: docker search "keyword"
3. private Registry를 구축하고 싶어요
docker run -d -p 5000:5000 --restart always --name registry registry:2
5-2실습내용을 밑에 더 추가해서 넣자 ... 5-1을 별로 쓸게없네 ..
실습편
Repository 운영하기
1.hub.docker.com에 컨테이너 업로드 및 다운로드
docker search를 통해 httpd 를 검색하자.
ubuntu@ip-172-31-45-232:~$ docker search httpd
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/search?term=httpd": dial unix /var/run/docker.sock: connect: permission denied
ubuntu@ip-172-31-45-232:~$ sudo chmod 666 /var/run/docker.sock
접근권한 오류가 발생하였다.
sudo chmod 666 /var/run/docker.sock 명령어를 통해 docker에 대한 접근권한을 666 으로 바꿔주었다.
docekr search 실행결과
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
httpd The Apache HTTP Server Project 4395 [OK]
clearlinux/httpd httpd HyperText Transfer Protocol (HTTP) ser… 2
paketobuildpacks/httpd 0
avenga/httpd-static 0
betterweb/httpd 0
centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or bui… 45
manageiq/httpd Container with httpd, built on CentOS for Ma… 1 [OK]
centos/httpd-24-centos8 1
dockerpinata/httpd 1
19022021/httpd-connection_test This httpd image will test the connectivity … 0
centos/httpd 36 [OK]
publici/httpd httpd:latest 1 [OK]
e2eteam/httpd 0
manasip/httpd 0
httpdocker/kubia 0
solsson/httpd-openidc mod_auth_openidc on official httpd image, ve… 2 [OK]
patrickha/httpd-err 0
httpdss/archerysec ArcherySec repository 0 [OK]
hypoport/httpd-cgi httpd-cgi 2 [OK]
manageiq/httpd_configmap_generator Httpd Configmap Generator 0 [OK]
amd64/httpd The Apache HTTP Server Project 0
dariko/httpd-rproxy-ldap Apache httpd reverse proxy with LDAP authent… 1 [OK]
inanimate/httpd-ssl A play container with httpd, ssl enabled, an… 1 [OK]
signiant/httpd httpd (apache2) base container with a custom… 0 [OK]
lead4good/httpd-fpm httpd server which connects via fcgi proxy h… 1 [OK]
docker pull httpd:latest 를 통해 다운로드받아보자
ubuntu@ip-172-31-45-232:~$ docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
f1f26f570256: Already exists
a6b093ae1967: Pull complete
6b400bbb27df: Pull complete
6e310dd059b6: Pull complete
471cb5914961: Pull complete
Digest: sha256:4055b18d92fd006f74d4a2aac172a371dc9a750eaa78000756dee55a9beb4625
Status: Downloaded newer image for httpd:latest
docker images 를 통한 이미지 조회
ubuntu@ip-172-31-45-232:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kimminwoo1234/webserver v1 09b848442d5b 22 hours ago 204MB
webserver v1 09b848442d5b 22 hours ago 204MB
hellojs latest 50dd87d32f95 22 hours ago 918MB
httpd latest dc1a95e13784 4 days ago 145MB
nginx latest 080ed0ed8312 13 days ago 142MB
docker login을 통해 로그인을 시도해보자.
ubuntu@ip-172-31-45-232:~$ 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:
Password:
WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
ubuntu@ip-172-31-45-232:~$
docker push kimminwoo1234/webserver:v1 를 통해 dockerhub registry에 업로드를 해보겠습니다.
ubuntu@ip-172-31-45-232:~$ docker push kimminwoo1234/webserver:v1
The push refers to repository [docker.io/kimminwoo1234/webserver]
ebbee34bc725: Layer already exists
29b27404d37a: Layer already exists
b7e0fa7bfe7f: Layer already exists
v1: digest: sha256:5a324652ae1a024c25f5394c2503dfab0657efbbd96f4cee8fa4390960894156 size: 948
결과:
2.Private Registry 운영하기
Docker hub 에서 registry 를 검색한다.
사용법 숙지
registry container 를 다운로드받고 레지스토리를 실행한다(5000번 포트로)
docker run -d -p 5000:5000 --restart always --name registry registry:2
ubuntu@ip-172-31-45-232:~$ docker run -d -p 5000:5000 --restart always --name registry registry:2
Unable to find image 'registry:2' locally
2: Pulling from library/registry
91d30c5bc195: Pull complete
65d52c8ad3c4: Pull complete
54f80cd081c9: Pull complete
ca8951d7f653: Pull complete
5ee46e9ce9b6: Pull complete
Digest: sha256:8c51be2f669c82da8015017ff1eae5e5155fcf707ba914c5c7b798fbeb03b50c
Status: Downloaded newer image for registry:2
80a7664ffdac671bfd24e93ee27f72c1388d76a55e18437b39398aa6f827bf61
docker ps 를 통해 private 컨테이너 저장소에 확인
ubuntu@ip-172-31-45-232:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80a7664ffdac registry:2 "/entrypoint.sh /etc…" About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp registry
docker tag 를 통해 docker image명을 hub와 일치시켜줘야한다.
ubuntu@ip-172-31-45-232:~$ docker tag httpd:latest localhost:5000/httpd:latest
docker private registry localhost에 push 해보자
ubuntu@ip-172-31-45-232:~$ docker push localhost:5000/httpd:latest
The push refers to repository [localhost:5000/httpd]
b034c88a4303: Pushed
b69cf1622315: Pushed
8065d3aedc6d: Pushed
d0dbdb0bf1f7: Pushed
3af14c9a24c9: Pushed
latest: digest: sha256:08ad58e94f2076237a8073a277575d3fa21f9cc4a1b0158143e4ae637f181658 size: 1366
자 이제 나의 local registry에 저장이 되었는지 확인해보겠습니다.
다음과 같은 경로로 cd 명령어를 통해 들어온다음 ls명령어로 디렉토리 조회해보겠습니다.
/var/lib/docker/volumes/195a537e5d2a8743e778bfc3eedd7ec483a05a3ad1a854ca79493fdcfffc35fd/_data#
root@ip-172-31-45-232:/var/lib/docker/volumes/195a537e5d2a8743e778bfc3eedd7ec483a05a3ad1a854ca79493fdcfffc35fd/_data# ls docker/registry/v2/repositories
httpd
해당하는경로에 httpd 가 들어왔으면 성공! 나의 localregistry에 이미지를 저장시켜보았습니다.
'따배도 스터디' 카테고리의 다른 글
6-2 Docker 컨테이너 사용하기 -실습편 (0) | 2023.04.21 |
---|---|
6-1 Docker 컨테이너 사용하기 -이론편 (0) | 2023.04.20 |
4-2 도커 컨테이너 만들어보기:실습편 (0) | 2023.04.10 |
4-1 도커 컨네이너 만들어보기 (0) | 2023.04.09 |
Docker 3-2 도커 컨테이너 살펴보기 실습편 (0) | 2023.04.09 |