docker搭建registery本地版本

$ docker run -d -p 5000:5000 --restart=always --name registry registry:2

docker会显示本地没有register:2

然后会从自己的仓库查找并且卸载这个镜像,然后启动.

检查成功启动的内容:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
efd78fe51f04        registry:2          "/entrypoint.sh /etc…"   4 minutes ago       Up 4 minutes        0.0.0.0:5000->5000/tcp   registry

 

拉取hello-world镜像:

$docker run hello-world

$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

创建tag:

$ docker tag hello-world localhost:5000/helloworld:latest

尝试推送:

 docker push localhost:5000/helloworld
The push refers to repository [localhost:5000/helloworld]
af0b15c8625b: Pushed
latest: digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a size: 524

强制删除hello-world后,本地将不再有hello-world镜像;

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
registry            2                   f32a97de94e1        2 weeks ago         25.8MB

尝试从本地私库拉取helloworld:

$ docker pull localhost:5000/helloworld
Using default tag: latest
latest: Pulling from helloworld
1b930d010525: Already exists
Digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
Status: Downloaded newer image for localhost:5000/helloworld:latest

 

停止registry:

$docker stop registry && docker rm -v registry

 

指定本地存储位置的registry:

docker run -d -p 5000:5000 --restart=always --name registry -v /opt/data:/var/lib/registry registry:2

 


版权声明:本文为achen0001原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。