* IP 一定是要 Core 能访问到的 IP,多网卡的情况下可以手动指定,单网卡可以参考以下脚本:
```bash
export IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
echo 'Current ip:' ${IP}
```
* 配置 Docker 的时候直接把配置存在 ```/etc/docker/daemon.json``` 即可,如果是在中国大陆可以加入以下2个选项来提升体验:
```bash
"dns": ["114.114.114.114"]
"registry-mirrors": ["https://registry.docker-cn.com"]
```
* 配置 tls 证书的时候一定要和选定的访问 IP 一致
以 CentOS 为例,最后我们得到脚本如下:
```bash
yum install -y docker-ce
mkdir -p /etc/docker/tls
echo "{
\"hosts\": [\"unix:///var/run/docker.sock\", \"tcp://${IP}:2376\"],
\"tlsverify\": true,
\"tlscacert\": \"/etc/docker/tls/ca.crt\",
\"tlscert\": \"/etc/docker/tls/server.crt\",
\"tlskey\": \"/etc/docker/tls/server.key\",
\"cluster-store\": \"etcd://${ERU_ETCD}\"
}" > /etc/docker/daemon.json
openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.crt -days 3650 -subj /C=CN
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj /CN=${IP}
openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in server.csr -out server.crt -days 3650
openssl req -newkey rsa:2048 -nodes -keyout client.key -out client.csr -subj /CN=client
openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in client.csr -out client.crt -days 3650
chmod 600 ca.key client.key server.key
rm -rf server.csr client.csr
mv ca.* client.* server.* /etc/docker/tls
```