guohl@ghl-MBP ? ~ ? docker run -d -p 5000:5000 registry
Unable to find image 'registry:latest' locally
6cfde7386ab2: Pull complete
9789d95d9fda: Pull complete
19443e64f223: Pull complete
b329371ab73c: Pull complete
f0daee9a4e8f: Pull complete
a66e50e56475: Pull complete
8ab3d2988df5: Pull complete
5f60fa7ea945: Pull complete
db22a140c899: Pull complete
5b2fff9306bd: Pull complete
511136ea3c5a: Already exists
f3c84ac3a053: Already exists
a1a958a24818: Already exists
9fec74352904: Already exists
d0955f21bf24: Already exists
registry:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Status: Downloaded newer image for registry:latest
8fb8e82e61822e593e10b59a4e7bbad18c789b34e3b38942d5b63dccb497ed09 上传镜像到私有仓库
创建好私有仓库之后,我们就可以向该仓库上传镜像,别人也可以从该仓库下载镜像了。
查看本地已有的镜像:
guohl@ghl-MBP ? ~ ? docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginx latest 637d3b2f5fb5 4 days ago 93.44 MB
mysql latest 0feafece277d 11 days ago 282.9 MB
wordpress latest f90659c8fdb9 2 weeks ago 451.5 MB Ubuntu latest d0955f21bf24 4 weeks ago 188.3 MB
google/golang latest 3cc1d7ae0e9c 11 weeks ago 611.3 MB
hello-world latest e45a5af57b00 3 months ago 910 B
通过 docker tage 命令将 hello-world 这个镜像标记为 192.168.59.104:5000/hello-world之后,再 push 到该镜像到私有仓库:
guohl@ghl-MBP ? ~ ? docker tag hello-world 192.168.59.104:5000/hello-world
guohl@ghl-MBP ? ~ ? docker push 192.168.59.104:5000/hello-world
FATA[0000] Error: v1 ping attempt failed with error: Get https://192.168.59.104:5000/v1/_ping: dial tcp 192.168.59.104:5000: connection refused. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 192.168.59.104:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.59.104:5000/ca.crt
发现报错,使用 SO上类似问题 的解决方法可以解决上面的错误:
To use the --insecure-registry option, add it to the file /var/lib/boot2docker/profile inside the boot2docker VM. You can get into the VM with boot2docker ssh. The file contents should look like:
EXTRA_ARGS="--insecure-registry REGISTRY_IP:PORT" You will then need to restart boot2docker (e.g. boot2docker restart).