我目前正在尝试弄清楚为什么
index.html
和 nginx 服务器的这种简单设置不起作用。
我有以下内容:
index.html
Dockerfile
index.html
包含:
<!DOCTYPE html>
<html>
<head>
<title>
First Web Page
</title>
</head>
<body>
Hello World! You are working!
</body>
</html>
Dockerfile
包含:
FROM ubuntu:22.04
RUN apt-get update
RUN apt-get install nginx -y
COPY index.html /var/www/html/
EXPOSE 80
CMD ["nginx","-g","daemon off;"]
根据无数教程,如果我创建图像并运行它,这应该可以工作:
docker build . -t my-web-site
docker run -p 8080:80 -d my-web-site
然而,我的容器不同意...
2023-04-25 21:40:57 nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
2023-04-25 21:40:57 nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
2023-04-25 21:40:58 nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
2023-04-25 21:40:58 nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
2023-04-25 21:40:58 nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
2023-04-25 21:40:58 nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
2023-04-25 21:40:59 nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
2023-04-25 21:40:59 nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
2023-04-25 21:40:59 nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
2023-04-25 21:40:59 nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
2023-04-25 21:41:00 nginx: [emerg] still could not bind()
让这个看似简单的任务失败,我做错了什么?