【问题标题】:nginx server not starting it throw an error bind() to 0.0.0.0:80 failed (13: Permission denied)nginx 服务器没有启动它会抛出错误 bind() to 0.0.0.0:80 failed (13: Permission denied)
【发布时间】:2021-05-26 07:09:22
【问题描述】:

我正在将 php symfony 基本欢迎页面项目配置到我正在使用图像的 docker 中

richarvey nginx-php-fpm

这有我需要用 docker 运行 php 框架的所有包(nginx、php、alpine、docker 标签) 我的 nginx 服务器不工作,当在我的终端(Ubuntu 20.04.2 LTS)中写入 nginx 时,我收到以下错误

nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

目录

project
├── app       
├── .git               
├── docker-compose.yml
├── Dockerfile
└── README.md

docker-compose.yml

version: '3.8'

services:   test-app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: test-app-container
    volumes:
      - ./app/:/var/www/html
    ports:
      - "8080:80"

Dockerfile

FROM richarvey/nginx-php-fpm:latest

ENV WEBROOT="/var/www/html/public"

COPY app/* /var/www/html/

WORKDIR /var/www/html

【问题讨论】:

  • 低于 1024 的端口需要 root 权限。好像是这样的错误。
  • 所以我需要将我的端口从 docker-compose.yml 更改为以下 8080:8080 或任何其他大于 80 的端口号
  • 当我更改端口时,它会在终端中引发同样的错误。
  • 让我知道我是否从 etc/nginx/default.conf 更改它?

标签: docker symfony nginx docker-compose


【解决方案1】:

我已经修复了图像版本和用户权限问题,为此我为项目构建添加了所有者和组的环境变量,以创建所需图像的容器

version: '3.8'

services:
  test-app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: test-app-container
    volumes:
      - ./app/:/var/www/html/
    environment:
      PGID: 1000
      PUID: 1000
    ports:
      - "8080:80"

【讨论】:

    猜你喜欢
    • 2013-08-31
    • 2013-06-09
    • 1970-01-01
    • 2020-01-15
    • 2013-04-05
    • 1970-01-01
    • 2022-01-02
    • 2015-11-21
    • 2014-10-13
    相关资源
    最近更新 更多