Py学习  »  docker

Docker容器状态未启动

jimbiz • 4 年前 • 1365 次点击  

状态:3秒前退出(0)

命令:

docker run -d -it -i -t --name test ubuntu sh -c "echo "Input website:"; read website; echo "Searching.."; sleep 1; curl http:\\$website;"
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129096
文章 [ 2 ]  |  最新文章 4 年前
Vova
Reply   •   1 楼
Vova    5 年前

你差一点就完成了,但却犯了个错误

http:\\ 

应该在哪里

http://

所以,字符串看起来像:

docker run -it --rm --name test ubuntu sh -c "echo 'Input website:'; read website; echo 'Searching..'; sleep 1; curl http://$website;"
saeed
Reply   •   2 楼
saeed    5 年前

你使用了多个 " 在你的指挥下 escape characters ' .你的命令应该是这样的:

docker run -d -it -i -t --name test ubuntu sh -c "echo 'Input website:'; read website; echo 'Searching..'; sleep 1; curl 'http:\\$website;'"

或者:

docker run -d -it -i -t --name test ubuntu sh -c "echo \"Input website:\"; read website; echo \"Searching..\"; sleep 1; curl 'http:\\$website;'"

或者如果它不起作用,你可以改变 http:// http:\/\/ 如果它仍然不起作用,这可能会对你有所帮助。