Unexpected situation out of a sudden: I was no longer able to start apache Docker containers on my Mac. Executing the CLI command docker compose up errored with:

Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:80 -> 0.0.0.0:0: listen tcp 0.0.0.0:80: bind: address already in use

Inspecting Docker containers for conflicting Ports

Upon checking my Docker containers with docker ps -a (Docker service inspection) showed no conflicting Port allocation of multiple containers. What is going on then?

A local apache httpd service is running

To my surprise, there was actually something shown from a local webserver:
a simple «It works!» apache default website…

Screenshot of local default Apache website stating «It works!»

Checking the «Activity Monitor.app» in macOS confirmed my suspicion: a local apache httpd instance from the root user was running – not from Docker, but from the macOS system.

SOLUTION: Stopping the local apache httpd webserver & freeing the Port for Docker

The resolution to the Docker error is easy: stopping apache and freeing up the Port :80 for Docker.

sudo apachectl stop

Now my apache Docker container could be started successfully again, as my host machine was no longer keeping the Port 80 busy! 🥳

P.s.: Visakh has written a readworthy explanation, why multiple Docker services on the same host Port are not working (which also applies to non-Docker services listening on the same Port).

Root cause: I installed Xcode 14!

I narrowed this issue – or better: «changed behaviour» – down to the root cause being a fresh Xcode 14 installation. Xcode nowadays uses some webserver functionality for something called «DocC documentation».

However, this installation on my Mac caused the local apache httpd service to be started and interrupting Docker. This even kept even happening after restarting Docker and macOS itself, without having Xcode open.

Share:
  • 0
  • 0

Questions? Suggestions? Let us know with a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.