我在脚本下运行并出现错误
#!/bin/bash
webproxy="webproxy-test-01"
webproxycurl="curl -k -s https://localhost:\${nginx_https_port}/HealthCheckService"
sudo docker exec $webproxy sh -c \'$webproxycurl\'
这是错误。-k: -c: line 0: unexpected EOF while looking for matching `''
-k: -c: line 1: syntax error: unexpected end of file
这是在shell提示符下起作用的命令$sudo docker exec webproxy-test-01 sh -c 'curl -k -s https://localhost:${nginx_https_port}/HealthCheckService'
HEALTHCHECK_OK
有人可以帮我解决这个错误。任何帮助将不胜感激。
最佳答案
尝试使用:
sudo docker exec $webproxy sh -c "$webproxycurl"
另外,请注意,请勿在sudo
中运行docker。 sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker
或注销/登录以激活对组的更改。 docker run hello-world
检查是否可以在没有sudo的情况下运行docker。检查this answer以获得更多详细信息。
关于bash - 寻找匹配的 `'时出现意外的EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63644875/