Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Ports Are Not Available" From Docker Container (MacOS) #61

Closed
AidanGood opened this issue Apr 24, 2023 · 48 comments
Closed

"Ports Are Not Available" From Docker Container (MacOS) #61

AidanGood opened this issue Apr 24, 2023 · 48 comments
Assignees
Labels
platform | macos Issue is on MacOS. type | report | incompatibility Incompatibility with an expectedly compatible suite (OS, tool, browser, etc).

Comments

@AidanGood
Copy link

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?

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

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?

Big oof apple lol. That is the default Flask port also. We're using FastAPI currently. I believe you can change the port in the docker compose file but I haven't personally tried running the back end on a different port.

@bigr00
Copy link

bigr00 commented Apr 24, 2023

I tried changing the port and unfortunately it breaks the frontend, have not found why yet.

@bigr00
Copy link

bigr00 commented Apr 24, 2023

I changed the port mapping in the Docker compose file:
Screenshot 2023-04-24 at 08 12 13

The docker container runs, FastAPI is up and running, but frontend does not connect to it:
Screenshot 2023-04-24 at 08 13 29

@bigr00
Copy link

bigr00 commented Apr 24, 2023

It's fair to say now that it does not work on MacOS currently.

@bigr00
Copy link

bigr00 commented Apr 24, 2023

The problem is with all the hardcoded URL-s in the frontend. Had to replace 31 port definitions, rebuild the Docker image with no cache enabled (uvicorn caches the initial port) and then finally got the website to work.

@Captain-Bacon
Copy link

If you turn off all the airplay you can get it to run, but then i find that i have 'network error' constantly. Same error as in the closed issue ticket. I am also running on a macbook, same as the other issues author.

@Captain-Bacon
Copy link

Captain-Bacon commented Apr 24, 2023

The problem is with all the hardcoded URL-s in the frontend. Had to replace 31 port definitions, rebuild the Docker image with no cache enabled (uvicorn caches the initial port) and then finally got the website to work.

@bigr00 any chance of a walkthough on this? I have 34 instances of '5000' showing up, and as you only mention 31, I assume that some of them should not be touched?

@dany-on-demand
Copy link
Contributor

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

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

@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.

@bigr00
Copy link

bigr00 commented Apr 24, 2023

The pyllamacpp non-compliance is cofirmed, it seems not to be correctly building in Docker for arm64.
ParisNeo/lollms-webui#73

@bigr00
Copy link

bigr00 commented Apr 24, 2023

So currently the following is needed to do:

  1. Remove pyllamaccp from requirements and delete llamacpp.py
  2. Replace all port 5000 occurrences with 5001 (yes, those are 34 occurrences hardcoded in the frontend)
  3. Run docker-compose -f docker-compose-mac.yml up -d --build

And now we have it working on arm64.

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

nomic-ai/pygpt4all#57

It might be worth seeing the latest comment on that one, might help with getting pyllamacpp working.

@Captain-Bacon
Copy link

@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.

@Josh-XT I've given this a go. The build went successfully, but I still have the Network Error. I'm going to guess that this was build for Arm64, and I'm on an Intel Chipset x64?

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

Correct, you can probably use the normal docker-compose in that case.

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

Please see #67 and pull the latest.

@Josh-XT Josh-XT added type | report | incompatibility Incompatibility with an expectedly compatible suite (OS, tool, browser, etc). reply needed | please retest Waiting for a retest from the creator of the issue. If not responded to in a week, may be closed. labels Apr 24, 2023
@Captain-Bacon
Copy link

Captain-Bacon commented Apr 24, 2023

@Josh-XT I maybe being utterly ignorant, but I'm not sure how that helps? Sorry!

running the normal docker - compose gives me a network error, and the docker for mac won't work as it's arm based, and i'm on the intel? I've tried both versions btw, and i get the Network Error on both. I get an exit with code 132 on the most recent pull.

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

The mac one would still work for you, it isn't arm based, it just makes your computer build the docker image instead of pulling it from GitHub.

You may need to try this since you've already tried running it before:

docker-compose down
docker-compose -f docker-compose-mac.yml down

Then do:

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

@Josh-XT Josh-XT changed the title MacOS 12+ uses port 5000 for AirPlay MacOS: Compatibility Issues Apr 24, 2023
@Aopenz
Copy link

Aopenz commented Apr 24, 2023

=> ERROR [base 7/12] RUN pip install --no-cache-dir -r requirements-mac 1.7s

[base 7/12] RUN pip install --no-cache-dir -r requirements-mac.txt:
#0 0.269 ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements-mac.txt'


failed to solve: executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements-mac.txt]: exit code: 1

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

=> ERROR [base 7/12] RUN pip install --no-cache-dir -r requirements-mac 1.7s

[base 7/12] RUN pip install --no-cache-dir -r requirements-mac.txt:
#0 0.269 ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements-mac.txt'

failed to solve: executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements-mac.txt]: exit code: 1

You'll need to pull the latest to get the file.

@avatarneil
Copy link

I believe that the Dockerfile-mac-backend file is missing a COPY requirements-mac.txt ./ statement. If you add that right after the line that copies requirements.txt, it ought to work.

@Captain-Bacon
Copy link

Captain-Bacon commented Apr 24, 2023

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

@Captain-Bacon
Copy link

Captain-Bacon commented Apr 24, 2023

maybe i spoke too soon:

0 65.39 Get:52 http://deb.debian.org/debian buster/main amd64 libssh2-1 amd64 1.8.0-2.1 [140 kB]
0 65.50 Get:53 http://deb.debian.org/debian-security buster/updates/main amd64 libcurl3-gnutls amd64 7.64.0-4+deb10u6 [333 kB]
0 65.65 Get:54 http://deb.debian.org/debian-security buster/updates/main amd64 libpcre2-8-0 amd64 10.32-5+deb10u1 [213 kB]
0 65.77 Get:55 http://deb.debian.org/debian buster/main amd64 liberror-perl all 0.17027-2 [30.9 kB]
0 65.85 Get:56 http://deb.debian.org/debian-security buster/updates/main amd64 git-man all 1:2.20.1-2+deb10u8 [1623 kB]
0 66.28 Get:57 http://deb.debian.org/debian-security buster/updates/main amd64 git amd64 1:2.20.1-2+deb10u8 [5631 kB]
0 68.08 W: http://deb.debian.org/debian/pool/main/m/mpclib3/libmpc3_1.1.0-1_amd64.deb: Automatically disabled Acquire::http::Pipeline-Depth due to incorrect response from server/proxy. (man 5 apt.conf)
0 68.08 E: Failed to fetch http://deb.debian.org/debian-security/pool/updates/main/k/krb5/libgssapi-krb5-2_1.17-3+deb10u5_amd64.deb 400 Bad Request [IP: 146.75.74.132 80]
0 68.08 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
0 68.08 Fetched 63.7 MB in 1min 7s (955 kB/s)

failed to solve: executor failed running [/bin/sh -c apt-get install -y --no-install-recommends git build-essential]: exit code: 100

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

Just pushed out an update to fix the dockerfile

@Captain-Bacon
Copy link

@Josh-XT
I keep failing at this point:

Screenshot 2023-04-24 at 16 39 49

@Captain-Bacon
Copy link

I've deleted the entire folder for Agent LLM, re-cloned the distro, got further this time, but now I'm stuck with the same Network Error when running. "docker-compose -f docker-compose-mac.yml up -d --build"

Screenshot 2023-04-24 at 16 49 13

@Aopenz
Copy link

Aopenz commented Apr 24, 2023

same Network Error when running

@Captain-Bacon
Copy link

@Josh-XT Just checking in - was wondering if there was any likelihood of an update today, as I'm on the edge of my seat!

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 24, 2023

@Josh-XT Just checking in - was wondering if there was any likelihood of an update today, as I'm on the edge of my seat!

Sorry, day job requiring my attention. :)

I am wondering if trying to do a docker prune. This will gut all of your docker stuff, so if you have other docker stuff running, it will break it, so maybe don't do it.

Use with caution. It will purge all volumes and containers for docker and make your docker like a fresh install.

docker system prune -a --volumes

@Captain-Bacon
Copy link

Captain-Bacon commented Apr 24, 2023 via email

@bozo32
Copy link

bozo32 commented Apr 24, 2023

did
docker-compose down
docker-compose -f docker-compose-mac.yml down
docker system prune -a --volumes (12 gb of things I'd forgotten existed poof :) )
docker-compose -f docker-compose-mac.yml up --build -d

install completed with no apparent errors
[+] Running 3/3
⠿ Network agent-llm_default Created 0.0s
⠿ Container agent-llm-backend-1 Started 0.5s
⠿ Container agent-llm-frontend-1 Started 0.7s

localhost:5000 is blank
localhost:5001 is {"detail":"Not Found"}
running m1 from a conda environment python 3.10 that I created using your requirements.txt...but that shouldn't make any difference should it?

-Peter

@alifanov
Copy link

I suppose the problem with env
Added console.log for JS app - process.env.NEXT_PUBLIC_API_URI=undefined

@Aopenz
Copy link

Aopenz commented Apr 25, 2023

‘docker system prune -a --volumes’,The command has been executed, Also re-cloned the program,but there is still a network error

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 25, 2023

Can you guys see if anything is any better with the latest release?

@Captain-Bacon
Copy link

Captain-Bacon commented Apr 25, 2023

Can you guys see if anything is any better with the latest release?

@Josh-XT 0 131.0 Get:11 http://deb.debian.org/debian buster/main amd64 xz-utils amd64 5.2.4-1+deb10u1 [183 kB]
#0 131.1 Fetched 61.6 MB in 2min 9s (477 kB/s)
#0 131.1 W: http://deb.debian.org/debian/pool/main/g/gcc-defaults/cpp_8.3.0-1_amd64.deb: Automatically disabled Acquire::http::Pipeline-Depth due to incorrect response from server/proxy. (man 5 apt.conf)
#0 131.1 E: Failed to fetch http://deb.debian.org/debian-security/pool/updates/main/k/krb5/libgssapi-krb5-2_1.17-3+deb10u5_amd64.deb 400 Bad Request [IP: 151.101.62.132 80]
#0 131.1 E: Failed to fetch http://deb.debian.org/debian/pool/main/b/binutils/binutils-common_2.31.1-16_amd64.deb Temporary failure resolving 'deb.debian.org' [IP: 151.101.62.132 80]
#0 131.1 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

failed to solve: executor failed running [/bin/sh -c apt-get install -y --no-install-recommends git build-essential]: exit code: 100

EDIT: Deleted the repo and re-cloned - getting a bit further this time...

@alifanov
Copy link

image

@Captain-Bacon
Copy link

Screenshot 2023-04-25 at 19 16 47

@bozo32
Copy link

bozo32 commented Apr 25, 2023

I'm getting the same as Mr Bacon
for context...clip from .env file

both are tested and known good.

=========================

AI PROVIDER: OPENAI

=========================

OPENAI_API_KEY="sk-whatever"

snip

=========================

AI PROVIDER: LLAMACPP

=========================

MODEL_PATH="/Users/peter/ai-computing-assistant/llama.cpp/models/7B/ggml-model-q4_0.bin"

Josh-XT added a commit that referenced this issue Apr 26, 2023
* Ooba endpoint update

* Switch to port 7437 from 5000

* Update port to 7437 from 5000
@Josh-XT
Copy link
Owner

Josh-XT commented Apr 26, 2023

I've updated the back end port to 7437. Please update to v1.1.0 and let me know if you're still having issues.

https://github.com/Josh-XT/Agent-LLM/releases/tag/v1.1.0

@Aopenz
Copy link

Aopenz commented Apr 26, 2023

Error!
Network Error @Josh-XT

@bozo32
Copy link

bozo32 commented Apr 26, 2023

just did a full prune and re-install

2023-04-26 08:43:16 (15,2 MB/s) - ‘docker-compose-mac.yml’ saved [574/574]
(agent-llm-3.10) peter@peter agent-llm % docker compose -f docker-compose-mac.yml up -d
[+] Running 0/1
⠙ frontend Pulling 1.1s
no matching manifest for linux/arm64/v8 in the manifest list entries
(agent-llm-3.10) peter@peter agent-llm %

@bozo32
Copy link

bozo32 commented Apr 26, 2023

the updated version above didn't work either.server dropped apparently. is there a debug stream somewhere I could be capturing that would be useful?

@JamesonRGrieve JamesonRGrieve added platform | macos Issue is on MacOS. and removed reply needed | please retest Waiting for a retest from the creator of the issue. If not responded to in a week, may be closed. labels Apr 27, 2023
@JamesonRGrieve JamesonRGrieve changed the title MacOS: Compatibility Issues "Ports Are Not Available" From Docker Container (MacOS) Apr 27, 2023
@bigr00
Copy link

bigr00 commented Apr 28, 2023

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

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 29, 2023

Can you try the latest? We did a bunch of bug fixes over the past 24 hours.

@Josh-XT
Copy link
Owner

Josh-XT commented Apr 29, 2023

Core of this main issue was resolved by changing our back end port. Other issues with docker not communicating back end with front end, please move that conversation to #79

@Josh-XT Josh-XT closed this as completed Apr 29, 2023
@Aopenz
Copy link

Aopenz commented Apr 29, 2023

Been following the updates, but unfortunately, have not used them successfully. Now the network error is solved, but the program doesn't do any work and the agent chat button is grayed out. It would be great if you could record a Youtube video with the detailed steps from installation to use. Thanks for your hard work! @Josh-XT

@bigr00
Copy link

bigr00 commented Apr 29, 2023

We have been bashing on this issue because we really want to use the library! You are doing awesome work, @Josh-XT !!!!!!

I completely agree with @Aopenz - we currently have no idea what are the expected features, working blind here. Would love to see how the frontend is supposed to behave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform | macos Issue is on MacOS. type | report | incompatibility Incompatibility with an expectedly compatible suite (OS, tool, browser, etc).
Projects
None yet
Development

No branches or pull requests

10 participants