Get the App
SLTechnology News&Howtos  ›  Servers  › 

7.docker-registry private warehouse

Shulou Source: shulou.com Published: 2022-06-03 10:20:19 12月06日 Update

1. Download private repository image

[root@docker03 ~] # docker pull registry Using default tag: latestlatest: Pulling from library/registryc87736221ed0: Pull complete 1cc8e0bb44df: Pull complete 54d33bcb37f5: Pull complete e8afc091c171: Pull complete b4541f6d3db6: Pull complete Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146Status: Downloaded newer image for registry:latestdocker.io/library/registry:latest

two。 Start mirroring

[root@docker03] # docker run-d-p 5000 restart=always-- name registry-v / opt/myregistry:/var/lib/registry registryc167a59c546c90e32bd0f15cc9b219555056d89b0f09af61f4b0e0ae8d930a82

3. Report an error on the first upload

[root@docker03 ~] # docker tag centos:7 10.0.0.13:5000/centos:7 [root@docker03 ~] # docker push 10.0.0.13:5000/centosThe push refers to repository [10.0.0.13:5000/centos] Get https://10.0.0.13:5000/v2/: http: server gave HTTP response to HTTPS client

4. The default is http, adding trust (files are not available by default)

Vim / etc/docker/daemon.json {"insecure-registries": ["10.0.0.13 insecure-registries 5000"]} # restart dockersystemctl restart docker

5. Upload (push) image test

Root@docker03 ~] # docker push 10.0.0.13:5000/centos:6.9 The push refers to repository [10.0.0.13:5000/cnetos] aaa5621d7c01: Pushed

6. Download (pull) Image Test

[root@docker03 ~] # docker pull 10.0.0.13:5000/centos:6.9

7. Delete the image in the private repository

# enter the private warehouse registry [root@docker03 ~] # docker exec-it registry/ bin/sh# to delete repo~ # rm-rf / var/lib/registry/docker/registry/v2/repositories/cnetos# clear blob~ # registry garbage-collect / etc/docker/registry/config.yml

8. Add authentication to registry

[root@docker03 ~] # yum install httpd-tools-y [root@docker03 ~] # mkdir / opt/registry-var/auth/-p [root@docker03 ~] # htpasswd-Bbn shuai 123456 > > / opt/registry-var/auth/htpasswd [root@docker03 ~] # docker run-d-p 5000 purse 5000-v / opt/registry-var/auth/:/auth/-v / opt/myregistry:/var/lib/registry-e "REGISTRY_AUTH=htpasswd"-e REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm "- e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd registry# cannot upload [root@docker03 ~] # docker tag centos:latest 10.0.0.13:5000/centos:7 [root@docker03 ~] # docker push 10.0.0.13:5000/centos:7 The push refers to repository [10.0.0.13:5000/centos] 9e607bb861a7: Preparing no basic auth credentials# login upload [root@docker03 ~] # docker login 10.0 without authentication .0.13: 5000Username: shuai Password: WARNING! Your password will be stored unencrypted in / root/.docker/config.json.Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded [root@docker03 ~] # docker push 10.0.0.13:5000/centos:7 The push refers to repository [10.0.0.13:5000/centos] 9e607bb861a7: Pushed 7: digest: sha256:6ab380c5a5acf71c1b6660d645d2cd79cc8ce91b38e0352cbf9561e050427baf size: 529# Logout [root@docker03 ~] # docker logout 10.0.0.13:5000Removing login credentials for 10.0.0.135000

9. Password file directory

[root@docker03 ~] # cat / root/.docker/config.json {"auths": {"10.0.0.13 auths": {"auth": "c2h2YWk6MTIzNDU2"}}, "HttpHeaders": {"User-Agent": "Docker-Client/19.03.3 (linux)"} # use base64 to authenticate c2h2YWk6MTIzNDU2=shuai:123456

Tags: Image warehouse private authentication file test clear password directory first time login Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL Linux vpn NVidia