按照書中所寫,輸入以下命令:
$ sudo docker run -d -p 80 --name static_web yorkz0909/static_web \ nginx -g "daemon off;"
來啟動(dòng)新的容器,容器貌似啟動(dòng)了,但是會(huì)報(bào)以下錯(cuò)誤:
35b5d1f047a51373ca71190b0eed504ba0540c32427f4637b967c7b4ad7fa217
docker: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting
container process caused \"exec: \\\" nginx\\\": executable file not found in $PATH\"\n".
搜索了一下原因,可能是因?yàn)樵趩?dòng)的時(shí)候命令不對,于是在命令中加入/bin/sh,重新起了個(gè)名字static_web2,否則會(huì)報(bào)錯(cuò)命名沖突:
報(bào)錯(cuò)內(nèi)容:
docker: Error response from daemon: Conflict. The name "/static_web1" is already in use by container
35b5d1f047a51373ca71190b0eed504ba0540c32427f4637b967c7b4ad7fa217. You have to remove (or rename) that container to be able to reuse that name..
輸入正確的命令:
$ sudo docker run -d -p 80 --name <span style="color:#FF0000;">static_web2</span> yorkz0909/static_web <span style="color:#FF0000;">/bin/sh</span> \ nginx -g "daemon off;"
d918395d551b582ae1a446ff119d4832fe9bfb4a65e91b2ea1a75e36ffec6743
運(yùn)行后沒有報(bào)錯(cuò),當(dāng)然,并不知道具體為什么,猜想可能是因?yàn)橹付ㄟ\(yùn)行的命令,加入了指定的/bin/sh命令后就可以了。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。