I am using python3.10 and building a basic Q&A chatbot. I have built docker image using below dockerfile:
FROM python:3.10.14-bookworm
WORKDIR /app
COPY ./app/requirements.txt .
RUN pip3 install -r requirements.txt
COPY . .
EXPOSE 8080
CMD ["streamlit", "run", "app/app.py", "--server.port", "8080"]
I used docker build -t chatbotimg .
command to build docker image and it got created as well, but when I tried to run it, it started like below:
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8080
Network URL: http://172.17.0.1:8080
External URL: http://105.222.203.146:8080
But when I clicked on the link, the browser wasn't working, it gave an error (Safari browser): Safari Can't open the page "localhost:8080" because safari Can't connect to the server "localhost". Can someone please help me resolving this issue?
You need to map ports on your computer to the container, try this:
docker build -t chatbotimg .
docker run -p 127.0.0.1:8080:8080 chatbotimg