[TODO]保護Docker daemon的socket

Docker Engine -> User guide -> Secure Engine -> Protect the Docker daemon socket

Protect the Docker daemon socket

默認的,Docker的運行通過non-networked Unix socket.當(dāng)然也可以通過HTTP socket進行通信。

如果你需要一種安全的網(wǎng)絡(luò)方式,你可以開啟TLS通過指定tlsverify標識并指明Docker的證書位置通過tlscacert標識去信任一個CA證書。

在daemon的模式下,將只會允許擁有CA簽名的證書的認證客戶端去鏈接。在client模式下,將通過這個CA簽名的證書連接到服務(wù)器。

警告 :使用TLS并管理CA是高級部分。請在生產(chǎn)環(huán)境使用之前熟悉OpenSSL,x509 ,和TLS。

警告 :這里的TLS命令在Linux下只會生成一個證書的工作集,Mac OS X的一些版本的OpenSSL與Docker需要的證書不兼容。

Create a CA, server and client key with OpenSSL

注意:替換下命例子中的$HOST和DNS名為你的Docker daemon的主機。

首先生成CA的私鑰和公鑰:

# ------------------生成CA私鑰 ca-key.pem-----------------
$ openssl genrsa -aes256 -out ca-key.pem 4096
Generating RSA private key, 4096 bit long modulus
............................................................................................................................................................................................++
........++
e is 65537 (0x10001)
Enter pass phrase for ca-key.pem:
Verifying - Enter pass phrase for ca-key.pem:

# ------------------生成CA公鑰 ca.pem-----------------------
$ openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
Enter pass phrase for ca-key.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) [AU]:
State or Province Name (full name) [Some-State]:Queensland
Locality Name (eg, city) []:Brisbane
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Docker Inc
Organizational Unit Name (eg, section) []:Sales
#Common Name 在這里 ?。。。。。。。?!
Common Name (e.g. server FQDN or YOUR name) []:$HOST
Email Address []:Sven@home.org.au

現(xiàn)在我們已經(jīng)有了一個CA,可以創(chuàng)建一個server key和certifivate signing request(CSR).確?!癈ommon Name”與你要連接的Docker的hostname匹配:

注意:替換下命例子中的$HOST和DNS名為你的Docker daemon的主機。

$ openssl genrsa -out server-key.pem 4096
Generating RSA private key, 4096 bit long modulus
.....................................................................++
.................................................................................................++
e is 65537 (0x10001)
$ openssl req -subj "/CN=$HOST" -sha256 -new -key server-key.pem -out server.csr

接下來,我們可以...

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容