CentOS Linux release 7.3.1611
Docker版本:17.06.0-ce
registry 仓库:
# mkdir /certs # openssl req -newkey rsa:2048 -nodes -sha256 -keyout /certs/domain.key -x509 -days 365 -out /certs/domain.crt Generating a 2048 bit RSA private key .........+++ ......+++ writing new private key to ‘/certs/domain.key‘ ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter ‘.‘, the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:beijing Locality Name (eg, city) [Default City]:beijing Organization Name (eg, company) [Default Company Ltd]:foo Organizational Unit Name (eg, section) []:bar Common Name (eg, your name or your server‘s hostname) []:mydocker.com Email Address []:360529415@qq.com
# cd /certs/ [root@host certs]# ll total 8 -rw-r--r-- 1 root root 1424 Oct 12 19:30 domain.crt -rw-r--r-- 1 root root 1704 Oct 12 19:30 domain.key
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest 52c70f4c9842 2 days ago 177MB registry latest 28525f9a6e46 3 weeks ago 33.2MB busybox latest 54511612f1c4 4 weeks ago 1.13MB # docker run -d -p 5000:5000 --restart=always --name registry -v /data01:/var/lib/registry -v /certs:/certs -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key registry bda33d3805bf235abb4e20f6bff7e2434701a5450aa1f42df26bfac68c4d934a
# vi /etc/hosts 10.246.106.231 host mydocker.com
# docker tag httpd:latest mydocker.com:5000/nuo/httpd:latest # docker images REPOSITORY TAG IMAGE ID CREATED SIZE mydocker.com:5000/nuo/httpd latest 52c70f4c9842 2 days ago 177MB httpd latest 52c70f4c9842 2 days ago 177MB registry latest 28525f9a6e46 3 weeks ago 33.2MB busybox latest 54511612f1c4 4 weeks ago 1.13MB # docker rmi mydocker.com:5000/nuo/httpd Untagged: mydocker.com:5000/nuo/httpd:latest Untagged: mydocker.com:5000/nuo/httpd@sha256:88053f79c62d0351b4dcab32ebdce904b707ce0f8e549b2f7c1bd5b2634b15e5
# docker tag prom/node-exporter:latest mydocker.com:5000/nuo/prom/node-exporter:latest # docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest 52c70f4c9842 3 days ago 177MB prom/prometheus latest 03f045a7680f 6 days ago 75.4MB prom/node-exporter latest 12d51ffa2b22 6 days ago 22.8MB mydocker.com:5000/nuo/prom/node-exporter latest 12d51ffa2b22 6 days ago 22.8MB sebp/elk latest ec32b207b10d 11 days ago 1.02GB grafana/grafana latest 1d2e2705fd26 2 weeks ago 303MB registry latest 28525f9a6e46 3 weeks ago 33.2MB busybox latest 54511612f1c4 4 weeks ago 1.13MB google/cadvisor latest f9ba08bafdea 7 months ago 57.3MB progrium/consul latest 09ea64205e55 2 years ago 69.4MB # docker push mydocker.com:5000/nuo/prom/node-exporter The push refers to a repository [mydocker.com:5000/nuo/prom/node-exporter] 5f70bf18a086: Pushed 1c7f6350717e: Pushed a349adf62fe1: Pushed c7300f623e77: Pushed latest: digest: sha256:57d9b335b593e4d0da1477d7c5c05f23d9c3dc6023b3e733deb627076d4596ed size: 1979 # docker rmi mydocker.com:5000/nuo/prom/node-exporter:latest Untagged: mydocker.com:5000/nuo/prom/node-exporter:latest Untagged: mydocker.com:5000/nuo/prom/node-exporter@sha256:57d9b335b593e4d0da1477d7c5c05f23d9c3dc6023b3e733deb627076d4596ed
# scp /certs/domain.crt 10.246.147.20:/etc/docker/certs.d/mydocker.com\:5000/ca.crt
client
# cat /etc/hosts 10.246.106.231 mydocker.com # cd /etc/docker/ [root@host01 docker]# ls ca.pem daemon.json key.json server-key.pem server.pem [root@host01 docker]# mkdir -p certs.d/mydocker.com:5000 [root@host01 docker]# cd certs.d/mydocker.com\:5000/ [root@host01 mydocker.com:5000]# ls ca.crt [root@host01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE prom/prometheus latest 03f045a7680f 5 days ago 75.4MB jdeathe/centos-ssh latest 514d36e6e77d 5 days ago 219MB prom/node-exporter latest 12d51ffa2b22 6 days ago 22.8MB grafana/grafana latest 1d2e2705fd26 2 weeks ago 303MB busybox latest efe10ee6727f 2 months ago 1.13MB google/cadvisor latest f9ba08bafdea 7 months ago 57.3MB [root@host01 ~]# vi /etc/hosts [root@host01 ~]# docker pull mydocker.com:5000/nuo/httpd Using default tag: latest latest: Pulling from nuo/httpd 85b1f47fba49: Pull complete 3dee1a596b5f: Pull complete 86144720cb98: Pull complete 23273e61b31a: Pull complete 011f98a84808: Pull complete 71f27eec7416: Pull complete b87d74086bb4: Pull complete Digest: sha256:88053f79c62d0351b4dcab32ebdce904b707ce0f8e549b2f7c1bd5b2634b15e5 Status: Downloaded newer image for mydocker.com:5000/nuo/httpd:latest [root@host01 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mydocker.com:5000/nuo/httpd latest 52c70f4c9842 2 days ago 177MB prom/prometheus latest 03f045a7680f 5 days ago 75.4MB jdeathe/centos-ssh latest 514d36e6e77d 5 days ago 219MB prom/node-exporter latest 12d51ffa2b22 6 days ago 22.8MB grafana/grafana latest 1d2e2705fd26 2 weeks ago 303MB busybox latest efe10ee6727f 2 months ago 1.13MB google/cadvisor latest f9ba08bafdea 7 months ago 57.3MB
# cd /etc/docker/certs.d/mydocker.com\:5000/ # curl --cacert ca.crt --basic https://mydocker.com:5000/v2/_catalog {"repositories":["nuo/httpd"]} # curl --cacert ca.crt --basic https://mydocker.com:5000/v2/nuo/httpd/tags/list {"name":"nuo/httpd","tags":["latest"]} # curl --cacert ca.crt --basic https://mydocker.com:5000/v2/_catalog {"repositories":["nuo/busybox","nuo/httpd"]} [root@host01 mydocker.com:5000]# docker pull mydocker.com:5000/nuo/busybox Using default tag: latest latest: Pulling from nuo/busybox 03b1be98f3f9: Pull complete Digest: sha256:030fcb92e1487b18c974784dcc110a93147c9fc402188370fbfd17efabffc6af Status: Downloaded newer image for mydocker.com:5000/nuo/busybox:latest [root@host01 mydocker.com:5000]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mydocker.com:5000/nuo/httpd latest 52c70f4c9842 2 days ago 177MB prom/prometheus latest 03f045a7680f 5 days ago 75.4MB jdeathe/centos-ssh latest 514d36e6e77d 5 days ago 219MB prom/node-exporter latest 12d51ffa2b22 6 days ago 22.8MB grafana/grafana latest 1d2e2705fd26 2 weeks ago 303MB mydocker.com:5000/nuo/busybox latest 54511612f1c4 4 weeks ago 1.13MB busybox latest efe10ee6727f 2 months ago 1.13MB google/cadvisor latest f9ba08bafdea 7 months ago 57.3MB # docker run -d -p 80:80 --name=httpd mydocker.com:5000/nuo/httpd c7fe9bd3679244e8ef6643ba62799882f8325fffe68e3542ed0d344acc94b3de [root@centos7 mydocker.com:5000]# [root@centos7 mydocker.com:5000]# [root@centos7 mydocker.com:5000]# [root@centos7 mydocker.com:5000]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c7fe9bd36792 mydocker.com:5000/nuo/httpd "httpd-foreground" 4 seconds ago Up 3 seconds 0.0.0.0:80->80/tcp httpd [root@centos7 mydocker.com:5000]# [root@centos7 mydocker.com:5000]# [root@centos7 mydocker.com:5000]# [root@centos7 mydocker.com:5000]# [root@centos7 mydocker.com:5000]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mydocker.com:5000/nuo/httpd latest 52c70f4c9842 3 days ago 177MB
本文出自 “一诺千金” 博客,请务必保留此出处http://hatech.blog.51cto.com/8360868/1972198
原文地址:http://hatech.blog.51cto.com/8360868/1972198