標籤:

Docker Remote API 開發(一)

基本常見的Docker Control Panel 都是收費的,所以手賤打算自己弄一個玩,技術棧:

  • nodejs
  • docker remote api v1.24
  • vuejs
  • element 前端UI

  • redis 數據存儲
  • GitHub - request/request: ???? Simplified HTTP request client. 替代curl發送請求
  • Socket.IO 通過socket處理實時日誌

預期效果圖:

因為我機器是使用Docker Machine創建,所以默認已經從Unix socket轉發到了tcp port,如果是自己配置,需要在node節點上修改配置文件:

root@node-1:~# cat /etc/default/dockernnDOCKER_OPTS=n-H tcp://0.0.0.0:2376n-H unix:///var/run/docker.sockn--storage-driver aufsn--tlsverifyn--tlscacert /etc/docker/ca.pemn--tlscert /etc/docker/server.pemn--tlskey /etc/docker/server-key.pemn--label provider=aliyunecsnnn

這裡注意一下-H 就是轉發的配置了,另外還有tls的驗證選項,詳細配置請看文檔:

  • Protect the Docker daemon socket

使用Docker Remote API v1.24,調用遠程介面測試:

curl -v -k -E https://{SERVER_IP}:2376/images/json n --cert ~/.docker/machine/machines/hz-1/cert.pem n --key ~/.docker/machine/machines/hz-1/key.pem n --cacert ~/.docker/machine/machines/hz-1/ca.pemn

可以拿到數據:

[n {n "Id":"sha256:6ff756f6fc44903216bf36e941db37ed5bb707c533c9c07e513d02fc7dfad4ad",n "ParentId":"",n "RepoTags":[n "redis:3.2.3-alpine"n ],n "RepoDigests":[n "redis@sha256:fe846dd3decd53475c7f6b007ccf10834bdd60d3a649ebdb69f43aa10393e80f"n ],n "Created":1474338745,n "Size":20379436,n "VirtualSize":20379436,n "Labels":{nn }n }n]n

待續。

---------分割線---------

curl問題:

OS X: Using PEM private keys fail with error: OSStatus -25299n

找到解決方法:

For anyone else getting to this issue when searching for "OSStatus -25299", this is how to convert a pem + cert to pkcs12..nnopenssl pkcs12 -export -in ./client.crt -inkey ./client.pem -out client.p12nnwhere client.crt is your cert, client.pem is your private key, and client.p12 is your new password encrypted cert/key pkcs12 container.nnWith that I was able to use curl correctly with something like:ncurl -v -k -E ./client.p12:password http://urln

更簡單的:

or just install curl with openssl support:nn$ brew install curl --with-openssln$ brew link curl --forcen$ brew --versionncurl 7.50.1 (x86_64-apple-darwin15.6.0) libcurl/7.50.1 OpenSSL/1.0.2h zlib/1.2.5nProtocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftpnFeatures: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSocketsn(Note: You will probably need to run brew uninstall curl if you have another version of cURL installed using Brew.)n

原貼地址:

OS X: Using PEM private keys fail with error: OSStatus -25299 · Issue #283 · curl/curl · GitHub


推薦閱讀:

docker的幾點疑問?
什麼是docker鏡像?
docker怎麼修改拉取源從指定的國內倉庫拉取鏡像?
如何基於Docker進行開發?
DaoCloud和雲雀到底誰家的技術比較強一些?VMware和微軟系的比較?

TAG:Docker |