大概意思是本地服务器 A 发送命令到指定服务器 B,使服务器 B 启动 nginx 容器,并且将服务器 B 的 /etc/hosts 记录添加到 nginx 容器中。远程执行命令如下:
$ ssh root@host "docker run -d --name nginx-test $(cat /etc/hosts | grep '^192'| awk '{print "--add-host " $2":"$1}' | awk '{if(NR%900==0){printf $0 "\n"}else{printf "%s ",$0}}') -p 80:80 nginx"
执行命令后没有按照预想的将服务器 B 的 hosts 记录添加到 nginx 容器中,而是把服务器 A 的 hosts 记录添加了进去。这种情况有无办法处理?谢谢。
