【以下的问题经过翻译处理】 在Amazon AMI上这个可以工作: ec2.InitCommand.shellCommand('sudo ls /etc/resolv.conf')
这个也可以工作 ec2.InitFile.fromFileInline('/etc/resolv2.conf', './myContent/resolv2.conf')
这个也可以工作 ec2.InitCommand.shellCommand('sudo chmod 777 /etc/resolv.conf')
但是这个不行 ec2.InitCommand.shellCommand('sudo rm -f /etc/resolv.conf')
这个也不行 ec2.InitCommand.shellCommand('sudo sed -i "s/^nameserver/#nameserver/g" /etc/resolv.conf')
。
我想这是权限问题。ls -al
的输出在这里:
-rw-r--r-- 1 root root 121 Apr 30 12:37 /etc/resolv.conf
文件内容是:
; generated by /sbin/dhclient-script
search eu-west-3.compute.internal
options timeout:2 attempts:5
nameserver 10.10.0.2