my docker file contains are below:
FROM python:3.10.11
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
EXPOSE 8000
# Command to run the app
but when I try to run docker container in port 8000, it runs in 8501 as shown in below:
docker build -t streamlit-meetingsumeriserqa:1.0 .
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
streamlit-meetingsumeriserqa 1.0 973c4ae49cd6 5 minutes ago 8.72GB
docker run -p 8000:8000 streamlit-meetingsumeriserqa:1.0
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://172.17.0.2:8501
External URL: http://49.37.72.174:8501
also in web browser, it is not opening at localhost:8501, so do we need to change any port or something.
also when I try to push docker container into azure container registry , by following quick start in portal itself. but when try to provide username and password it gives me client timeout error. as shown in below:
docker login meetingsummeriser.azurecr.io
Username: meetingsummeriser
Password:
Error response from daemon: Get "
https://meetingsummeriser.azurecr.io/v2/":
net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
also our web app supports CORS for that we are using:
python -m streamlit run Login.py --server.port 8000 --server.address 0.0.0.0 --server.enableCORS=false --server.enableXsrfProtection=false
apart from above issue, just wanted to know as streamlit runs on port 8501 but azure web app supports port 8000, so what code changes I have to do?
As I am new to this any help will be thankful.
Check the below steps to deploy streamlit app to Azure app service using Azure Container Registry and Docker.
Thanks @docs.streamlit.io for the explanation.
I tried sample Code from this Documentation
In CMD I defined the port where I want to run app.
Dockerfile:
FROM python:3.12
WORKDIR /app
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
COPY . /app/
EXPOSE 8000
CMD ["streamlit", "run", "app.py", "--server.port=8000", "--server.address=0.0.0.0"]
In requirements.txt you need to add streamlit
package.
streamlit
In Docker Run command you can define Any local port which you want to map with docker port.
By using below commands, I build and run the docker Image locally.
docker build -t <ImageName> .
docker run -d -p <LocalPort>:<HostPortInDocker> <ImageName>
Local Output:
I used below Commands to push My local image to Azure Container Registry.
az acr login --n<AzureContainerRegistryName>.azurecr.io
docker tag <ImageName> <AzureContainerRegistryName>.azurecr.io/<ImageName>:<tag>
docker push <AzureContainerRegistryName>.azurecr.io/<ImageName>:<tag>
Next:Container
button as shown below.Azure App Service Output: