Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
Docker-compose can't start apache server

When i'm running sudo docker-compose up inside my dir, i get this error. I'm trying to make a container, that host a php website, where you can do whoami on it. Thanks

(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
| no listening sockets available, shutting down
| AH00015: Unable to open logs

Dockerfile:

FROM ubuntu:16.04

RUN apt update

RUN apt install -y apache2 php libapache2-mod-php 

RUN useradd -d /home/cp/ -m -s /bin/nologin cp

WORKDIR /home/cp

COPY source .

USER cp

ENTRYPOINT service apache2 start && /bin/bash

docker-compose.yml

version: '2'

services:
   filebrowser:
        build: .
        ports:
            - '8000:80'
        stdin_open: true
        tty: true
        volumes:
            - ./source:/var/www/html
            - ./logs:/var/log/apache2
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

There's a long-standing general rule in Unix-like operating systems that only the root user can open "low" ports 0-1023. Since you're trying to run Apache on the default HTTP port 80, but you're running it as a non-root user, you're getting the "permission denied" error you see.

The absolute easiest answer here is to use a prebuilt image that has PHP and Apache preinstalled. The Docker Hub php image includes a variant of this. You can use a simpler Dockerfile:

FROM php:7.4-apache
# Has Apache, mod-php preinstalled and a correct CMD already,
# so the only thing you need to do is
COPY source /var/www/html

# If you want to run as a non-root user, you can specify
RUN useradd -r -U cp
ENV APACHE_RUN_USER cp
ENV APACHE_RUN_GROUP cp

With the matching docker-compose.yml

version: '3' # version 2 vs 3 doesn't really matter
services:
  filebrowser:
    build: .
    ports:
      - '8000:80'
    volumes:
      - ./logs:/var/log/apache2

If you want to build things up from scratch, the next easiest option would be the Apache User directive: have your container start as root (so it can bind to port 80) but then instruct Apache to switch to the unprivileged user once it's started up. The standard php:...-apache image has an option to do this on its own which I've shown above.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!