在本地建立docker的registry

脱缰的野猪發表於2024-08-22

參考文件:https://ken.io/note/docker-private-image-server-deploy

1. 訪問在本地建立docker的registry預設是不需要輸入使用者名稱,密碼的,公司內網或開發小組內部使用起來很方便,但是直接pull會報錯:

$ docker pull 192.168.1.13:5000/alpine:latest

Error response from daemon: Get "https://192.168.1.13:5000/v2/": http: server gave HTTP response to HTTPS client

其中192.168.1.13:5000是之前配好的本地的registry。

解決的辦法是建立/修改配置檔案:

$ sudo vim /etc/docker/daemon.json

並保證daemon.json檔案中有如下內容:

$ cat /etc/docker/daemon.json 
{
    "insecure-registries": [
        "192.168.1.13:5000"
    ]
}

然後重啟 docker 服務

$ sudo systemctl stop docker
$ sudo systemctl start docker

再次嘗試拉取Image,成功

$ docker pull 192.168.1.13:5000/alpine:latest
latest: Pulling from alpine
c6a83fedfae6: Pull complete 
Digest: sha256:eddacbc7e24bf8799a4ed3cdcfa50d4b88a323695ad80f317b6629883b2c2a78
Status: Downloaded newer image for 192.168.1.13:5000/alpine:latest
192.168.1.13:5000/alpine:latest

$ docker images
REPOSITORY                 TAG       IMAGE ID       CREATED       SIZE
192.168.1.13:5000/alpine   latest    324bc02ae123   4 weeks ago   7.8MB

相關文章