When i run the docker run command and hit the “http://172.17.0.2:8501”, my streamlit app output should be open in my Winodws 11 OS.
Actual behavior
Hello, I’m new to Docker. Please forgive me if i made any mistake. my problem is : I’m able build and to run my docker images as “iris” and got the url as “Network URL: http://172.17.0.2:8501” , but when i hit the my url i’m not seeing my streamlit results.
Please help me on this:
Here my my details :
OS : Windows 11
Docker file is:
# Use the official Python image
FROM python:3.11.7
# Set the working directory inside the container
WORKDIR /app
# Copy the requirements.txt file first to leverage Docker cache
COPY requirements.txt .
# Install required Python packages
RUN pip install -r requirements.txt
# Copy the rest of the application files to the container's working directory
COPY . .
# Expose the port that Streamlit will run on
EXPOSE 8501
# Command to run your Streamlit application
CMD ["streamlit", "run", "app.py"]
To explain the command: The -p parameter is the parameter to map a port from the host to the container. This is used when the container is running on a NAT network. NAT networks are networks on which an internal virtual switch is used between the host and containers. The containers can access the internet, but in order to access the ports on the container, you need to map them between the host and that particular container you are running. Note that in this case you can map a port just once to a single container. If you have more than one container running, you need to use another port.
Hi Sir,
As you mentioned, I have run the command “docker run -p 8501:8501 iris” but still the issue is not resolved. still i’m getting the same error msg as “This site can’t be reached”
Oh. I missed the IP you are trying to get to. Since you mapped the port from the host to the container, you should access: http://127.0.0.1:8501. The IP address you tried to access the one from the container and you can’t access that directly.