服務器docker
客戶端macos
registry
服務docker run -d -p 5000:5000 --restart always \ -v /root/docker-registry/data/registry:/var/lib/registry \ -v /root/docker-registry/config.yml:/etc/docker/registry/config.yml \ --name my-registry registry:latest
config.yml
version: 0.1 log: fields: service: registry storage: delete: enabled: true cache: blobdescriptor: inmemory filesystem: rootdirectory: /var/lib/registry http: addr: :5000 headers: X-Content-Type-Options: [nosniff] health: storagedriver: enabled: true interval: 10s threshold: 3
vim /usr/lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd --insecure-registry 172.0.0.10:5000 systemctl daemon-reload systemctl restart docker
docker build -t 172.17.0.10:5000/my-app:1.0.1 . docker push 172.17.0.10:5000/my-app:1.0.1
tag
服務器上保留一個 latest
版本docker tag 172.17.0.10:5000/my-app:1.0.1 172.17.0.10:5000/my-app:latest docker push 172.17.0.10:5000/my-app:latest
查看vim
http://172.17.0.10:5000/v2/_catalog
http://172.17.0.10:5000/v2/image_name/tags/list
docker pull 172.17.0.10:5000/my-app:1.0.1
cat /root/docker-registry/data/registry/docker/registry/v2/repositories/my-app/_manifests/tags/1.0.1/current sha256:0599d30a8dc59cb316f8024db1490fa38aa7f98739d73afb28eb6f1d1655bb46[root@vm03 current]# pwd
DELETE /v2/<name>/manifests/<reference> name:鏡像名稱 reference: 鏡像對應sha256值
curl -I -X DELETE http://172.17.0.10:5000/v2/my-app/manifests/sha256:6a67ba482a8dd4f8143ac96b1dcffa5e45af95b8d3e37aeba72401a5afd7ab8e
docker exec -it f70d0c79e6d546d4 sh ~ # du -chs /var/lib/registry/ 182.4M /var/lib/registry/ 182.4M total
registry garbage-collect /etc/docker/registry/config.yml
docker rmi -f $(docker images | grep my-app)
Portainer
docker run -d -p 9100:9000 \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock \ --name prtainer-local \ portainer/portainer
© 會煮咖啡的貓咪windows