widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.9k stars 140 forks source link

Running solara app in a docker container with ipv6 #112

Open legout opened 1 year ago

legout commented 1 year ago

Hi guys,

I am not able to run my solara app in a docker container. Running the docker container results in the following error:

ERROR: [Errno 99] error while attempting to bind on address ('::1', 8765, 0, 0): cannot assign requested address

Here is what my Dockerfile looks like

#
# Build image
#

FROM python:3.11-slim as builder

ENV PYTHONFAULTHANDLER=1 \
    PYTHONHASHSEED=random \
    PYTHONUNBUFFERED=1 \
    POETRY_HOME=/opt/poetry

WORKDIR /app
COPY . .

RUN apt update -y && apt upgrade -y && apt install curl -y
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN ${POETRY_HOME}/bin/poetry config virtualenvs.create false 
RUN ${POETRY_HOME}/bin/poetry install --no-dev 
RUN ${POETRY_HOME}/bin/poetry export -f requirements.txt >> requirements.txt

#
# Prod image
#

FROM python:3.11-slim AS runtime

WORKDIR /app
COPY . .
COPY --from=builder /app/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 8765
CMD ["solara", "run", "src/app.py"]
legout commented 1 year ago

Solved the problem by adding --host=0.0.0.0 to solara run in the Dockerfile.


...

CMD ["solara", "run", "src/app.py", "--host=0.0.0.0"]
maartenbreddels commented 1 year ago

Thanks for reporting this and giving a solution. It would be nice if solara would work without this, so I'll keep it open for now.

Marsh-sudo commented 1 year ago

Would like to try solving this if possible

maartenbreddels commented 1 year ago

Great, looking forward to hearing about it. Even if you don’t solve it right away, please report what you found!

rmorshea commented 1 year ago

I'm pretty sure this is expected and not a problem with Solara.

maartenbreddels commented 1 year ago

Hi Ryan, thanks for chiming in.

I don't think the issue in that link is what is happening here (although very important). I think here the ::1 that we see in the error message comes from IPV6, which is probably used in combination with https://docs.python.org/3/library/socket.html#socket.AF_INET (and not AF_INET6)

Marsh-sudo commented 1 year ago

Thanks for reporting this and giving a solution. It would be nice if solara would work without this, so I'll keep it open for now.

So would you like the app in the container to run without ipv6 or with it so i can give a straight forward answer kindly

giswqs commented 1 year ago

@legout Thank you for sharing the solution. I was able to create a Dockerfile and deployed it on Hugging Face. Excited to create more mapping apps with solara!

App: https://giswqs-solara.hf.space Source code: https://huggingface.co/spaces/giswqs/solara/tree/main

maartenbreddels commented 1 year ago

So would you like the app in the container to run without ipv6 or with it so i can give a straight forward answer kindly

Sorry, I missed this question. I actually don't really understand why this is happening. All I know is that it would be nice if it worked out of the box.

maartenbreddels commented 1 year ago

I think this is a 'normal' issue in docker, but we now document this at https://solara.dev/docs/deploying/self-hosted