nignx - docker內(nèi)nginx 80端口被占用
問題描述
[root@8f52078ea4e6 config]# nginxnginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx: [emerg] still could not bind()
docker容器配置的端口對應(yīng)關(guān)系: 22/tcp, 0.0.0.0:80->80/tcp
問題解答
回答1:不是很確定,但是和docker的端口映射應(yīng)該是沒關(guān)系的,docker的關(guān)系映射相當于是再virtual box里面配了一個端口匹配規(guī)則,不會占用這個端口的,相當于外部端口轉(zhuǎn)發(fā)到內(nèi)部容器端口里。所以你這個錯誤應(yīng)該是docker內(nèi)部端口被占了。試一下lsof -i :80看看
回答2:用的什么鏡像? 如果官方的nginx的話, nginx進程已經(jīng)啟動了, 這時你當然不能再在80上啟動另一個
回答3:題主可以進入nginx的docker container實例,查看一下nginx是否已經(jīng)啟動:
ps -ef | grep nginx# ornetstat -ntpl | grep 80
如果已經(jīng)啟動,則不需要在重復(fù)啟動了
回答4:你這已經(jīng)是在容器中了吧,你的nginx容器啟動后,80端口就已經(jīng)起來了,你在運行nginx,肯定顯示被占用了。
相關(guān)文章:
1. docker網(wǎng)絡(luò)端口映射,沒有方便點的操作方法么?2. dockerfile - [docker build image失敗- npm install]3. 前端 - 請教一下CSS3中translateZ和rotateY書寫順序的問題4. css3 實現(xiàn)一個線性漸變出現(xiàn)的問題?5. javascript - 微信同屏播放器,長按二維碼無法識別6. javascript - sublime快鍵鍵問題7. javascript - 如何使用js主動觸發(fā)事件?8. javascript - 微信內(nèi)置瀏覽器的ua是多少?9. java - PHP開發(fā)微信無法獲取到signature,timestamp,nonce10. css3 - CSS中first-child無效
