AGiXT: "Ports Are Not Available" From Docker Container (MacOS)

When trying to run the docker container, I’d get:

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

After looking around for what was using this port, I discovered that since MacOS 12 port 5000 (and 7000) is used for AirPlay. Simple solution is to turn off AirPlay Reciever in the settings, or change the port used by the container, but figured I’d post this here for anyone else who is using a mac and running into the same issue. Might also want to mention this somewhere in the readme?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 48 (15 by maintainers)

Commits related to this issue

Most upvoted comments

After prune and reinstall and a modification to the dockerfiles to include arm64, it works! Nice job!

So for an M1 Macbook I had to do the following changes:

  1. Change the frontend Dockerfile Screenshot 2023-04-28 at 09 54 47
  2. Change the backend Dockerfile-backend Screenshot 2023-04-28 at 09 55 24
  3. Change docker-compose-mac.yml Screenshot 2023-04-28 at 09 55 41

Then a good old docker prune and 574 seconds later: Screenshot 2023-04-28 at 09 56 39

So now I got to a better state with the frontend itself, it now at least shows when the task starts, but does not update the frontend with anything going on in the backend afterwards. I would say this is a better state than before, but ultimately still not usable, as there are no updates coming to the frontend.

I looked into if it’s possible to detect the architecture of the system in Docker setup and unfortunately the only good solution I was able to find is an environment variable setup that needs to be executed from a separate script:

build.sh:


if [ "$(uname -sm)" == "Darwin arm64" ]; then
  export DOCKERFILE_BACKEND="Dockerfile-backend-m1"
else
  export DOCKERFILE_BACKEND="Dockerfile-backend"
fi

docker compose up -d

Dockerfile-backend:

backend:
  build:
    context: .
    dockerfile: ${DOCKERFILE_BACKEND}

And then:

chmod +x build.sh
./start.sh

Just pushed out an update to fix the dockerfile

the mac version needs the following bold added:

Install FastAPI app dependencies FROM python:3.10-slim-buster AS base WORKDIR /app COPY requirements -mac.txt ./ RUN apt-get update RUN apt-get install -y --no-install-recommends git build-essential RUN pip install --upgrade pip RUN pip install --no-cache-dir -r requirements.txt RUN apt-get remove -y git build-essential RUN apt-get install libgomp1 -y RUN apt-get install git -y RUN apt-get autoremove -y RUN rm -rf /var/lib/apt/lists/*

Run FastAPI app with Uvicorn FROM base AS uvicorn COPY . /app EXPOSE 5000 CMD [“uvicorn”, “app:app”, “–host”, “0.0.0.0”, “–port”, “5000”]

then all is golden

@bigr00 can you make a PR with just the changes you made?

Just pushed out a docker-compose-mac.yml matching @bigr00’s example above.

Mac Users:

docker-compose -f docker-compose-mac.yml up -d --build

Please give it a try and let me know how it goes.