Why do I have to build images every time the contents of the file corresponding to my workdir change, and then the container will take effect?

  docker, question

The dockerfile has not changed, but the file outside the container corresponding to workdir has changed.

  1. Is this necessary? If so, is it to use Docker Compose-Up to automatically simplify the process?

  2. If not, is it because of my dockerfile problem?
    Dockerfile is as follows:

    FROM ubuntu
     MAINTAINER Tarty.Phoenix   <tartyphoenix@gmail.com >
     RUN apt-get update
     RUN apt-get install -y -q python-all python-pip libffi-dev
     RUN apt-get install -y -q python-dev build-essential
     ADD ./flask_pure/requirements.txt /tmp/requirements.txt
     RUN pip install -qr /tmp/requirements.txt
     
     ADD ./flask_pure /opt/flask_pure/
     WORKDIR /opt/flask_pure
     
     EXPOSE 80
     CMD ["python", "manage.py", "runserver"]
  1. First of all, the directory represented by workdir is the directory inside the container, not host’s.

  2. The following changes need to be build image

    • Dockerfile itself changes

    • Source file change for COPY/ADD instruction

  3. Docker-compose supports rebuilding Image at runtime

    service:
     - build: <image_base_dir>