Wrong Dockerfile configuration on Deploy Streamlit using Docker docs page

Open
#968 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
docker, python

Research direction

Open the Deploy Streamlit using Docker page and inspect the Dockerfile example around WORKDIR, git clone, and pip3 install. Build the documented example to confirm the reported failure and verify that the published instructions complete successfully with the intended working directory.

Written by the indexing model from the issue text.

Description

Checklist
  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.
Summary

Hey

Today by following the manual at Deploy Streamlit using Docker (https://docs.streamlit.io/knowledge-base/tutorials/deploy/docker) I run into the problem of setting a WORKDIR for the Docker.

The WORKDIR has to be moved after the RUN git clone method for the Docker to set the WORKDIR correctly. Otherwise, it results in Docker being unable to set the WORKDIR and default to running the commands in its directory.

This way the docker build fails at RUN pip3 install -r requirements.txt

Wrong version:

# app/Dockerfile

FROM python:3.9-slim

WORKDIR /app

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/streamlit/streamlit-example.git .

RUN pip3 install -r requirements.txt

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]

Corrected version:

# app/Dockerfile

FROM python:3.9-slim

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    && rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/streamlit/streamlit-example.git .

WORKDIR /app

RUN pip3 install -r requirements.txt

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]

ran

Reproducible Code Example

No response

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?
  • Yes, this used to work in a previous version.
Debug info
  • Streamlit version:
  • Python version:
  • Operating System:
  • Browser:
Additional Information

No response

Dominant language
JavaScript
Stars
178
Forks
705
Avg merge
1d 13h
Merged PRs (30d)
39

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from streamlit/docs

All issues in streamlit/docs

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.