安装依赖 yum -y install gcc make file && yum -y install tar pcre-devel pcre-staticopenssl openssl-devel httpd-tools 配置SSL
(1) 编辑/etc/hosts,把docker.yy.com的ip地址添加进来,例如: 192.168.2.114 docker.yy.com (2) 生成根密钥先把“ /etc/pki/CA/cacert.pem /etc/pki/CA/index.txt /etc/pki/CA/index.txt.attr /etc/pki/CA/index.txt.old /etc/pki/CA/serial /etc/pki/CA/serial.old ” 删除掉! cd /etc/pki/CA/ openssl genrsa -out private/cakey.pem 2048 (3) 生成根证书 openssl req -new -x509 -key private/cakey.pem -out cacert.pem 输出: 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]:youyuan Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server"s hostname) []:docker.yy.com Email Address []: “ 会提示输入一些内容,因为是私有的,所以可以随便输入,最好记住能与后面保持一致,特别是"Common Name”。上面的自签证书cacert.pem应该生成在/etc/pki/CA下。 ” (4) 为我们的nginx web服务器生成ssl密钥 mkdir -p /etc/nginx/ssl cd /etc/nginx/ssl openssl genrsa -out nginx.key 2048 “ 我们的CA中心与要申请证书的服务器是同一个,否则应该是在另一台需要用到证书的服务器上生成。 ” (5) 为nginx生成证书签署请求 openssl req -new -key nginx.key -out nginx.csr 输出: 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]:youyuan Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server"s hostname) []:docker.yy.com Email Address []:Please enter the following "extra" attributes to be sent with your certificate request A challenge password []: An optional company name []: “ 同样会提示输入一些内容,Commone Name一定要是你要授予证书的服务器域名或主机名,challenge password不填。 ” (6) 私有CA根据请求来签发证书 touch /etc/pki/CA/index.txt touch /etc/pki/CA/serial echo 00 > /etc/pki/CA/serial openssl ca -in nginx.csr -out nginx.crt 输出: Using configuration from /etc/pki/tls/openssl.cnf Check that the request matches the signature Signature ok Certificate Details: Serial Number: 0 (0x0) Validity Not Before: Dec 9 09:59:20 2014 GMT Not After : Dec 9 09:59:20 2015 GMT Subject: countryName = CN stateOrProvinceName = beijing organizationName = youyuan commonName = docker.yy.com X509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: 5D:6B:02:FF:9E:F8:EA:1B:73:19:47:39:4F:88:93:9F:E7:AC:A5:66 X509v3 Authority Key Identifier: keyid:46:DC:F1:A5:6F:39:EC:6E:77:03:3B:C4:34:03:7E:B8:0A:ED:99:41Certificate is to be certified until Dec 9 09:59:20 2015 GMT (365 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated “ 同样会提示输入一些内容,选择y就可以了! ”
2. 查看image的id执行docker images 输出: root@pts/0 # docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos centos6 25c5298b1a36 8 days ago 215.8 MB 3. 给image赋予一个私有仓库的tagdocker tag 25c5298b1a36 docker.yy.com/centos:centos6
5. 查看imagedocker images 输出: root@pts/0 # docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos centos6 25c5298b1a36 8 days ago 215.8 MB docker.yy.com/centos centos6 25c5298b1a36 8 days ago 215.8 MB [X] Client端,操作私有仓库的步骤:
1. 从私有仓库pull下来image! docker pull docker.yy.com/centos:centos6 2. 查看imagedocker images 输出: root@pts/0 # docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE docker.yy.com/centos centos6 25c5298b1a36 8 days ago 215.8 MB
Docker的Web管理界面Shipyard
[0] 编辑/etc/sysconfig/docker文件在DOCKER_OPTS里添加-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock,例如: DOCKER_OPTS="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --insecure-registry docker.yy.com --tlsverify --tlscacert /etc/pki/CA/cacert.pem --registry-mirror=http://d194d5cb.m.daocloud.io" [1] Start an data volume instance of RethinkDB: docker run -it -d --name shipyard-rethinkdb-data --entrypoint /bin/bash shipyard/rethinkdb -l [2] Start RethinkDB with using the data volume container: docker run -it -P -d --name shipyard-rethinkdb --volumes-from shipyard-rethinkdb-data shipyard/rethinkdb “ If your server is directly accessible on Internet, please note your RethinkDB installation may publicly listen to ports 49153 (local instance), 49154 (cluster) and 49155 (web interface) and so accessible to all. ” [3] Start the Shipyard controller: docker run -it -p 8080:8080 -d --name shipyard --link shipyard-rethinkdb:rethinkdb shipyard/shipyard “ Shipyard will create a default user account with the usernameadmin and the passwordshipyard. You should then be able to open a browser tohttp://<your-host-ip>:8080and see the Shipyard login. ” 附录: